‪TYPO3CMS  9.5
TranslatedContentTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
21 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
22 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\ResponseContent;
23 
34 {
35  const ‪VALUE_PageId = 89;
36  const ‪TABLE_Content = 'tt_content';
37  const ‪TABLE_Pages = 'pages';
38 
42  protected ‪$scenarioDataSetDirectory = 'typo3/sysext/frontend/Tests/Functional/Rendering/DataSet/';
43 
47  protected ‪$testExtensionsToLoad = ['typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example'];
48 
52  protected ‪$coreExtensionsToLoad = ['extbase', 'fluid'];
53 
57  protected ‪$objectManager;
58 
62  protected ‪$contentRepository;
63 
71  'FE' => [
72  'pageNotFound_handling' => 'READFILE:typo3/sysext/frontend/Tests/Functional/Rendering/DataSet/404Template.html'
73  ]
74  ];
75 
79  protected ‪$pathsToLinkInTestInstance = [
80  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/AdditionalConfiguration.php' => 'typo3conf/AdditionalConfiguration.php',
81  'typo3/sysext/frontend/Tests/Functional/Fixtures/Images' => 'fileadmin/user_upload'
82  ];
83 
84  protected function ‪setUp()
85  {
86  parent::setUp();
87  $this->‪importScenarioDataSet('LiveDefaultPages');
88  $this->‪importScenarioDataSet('LiveDefaultElements');
89 
90  $this->objectManager = GeneralUtility::makeInstance(\‪TYPO3\CMS\‪Extbase\Object\ObjectManager::class);
91  $this->contentRepository = $this->objectManager->get(\‪ExtbaseTeam\BlogExample\Domain\Repository\TtContentRepository::class);
92  $this->setUpFrontendRootPage(1, [
93  'typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example/Configuration/TypoScript/setup.typoscript',
94  'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/Frontend/ContentJsonRenderer.typoscript'
95 
96  ]);
97  $this->addTypoScriptToTemplateRecord(
98  1,
99  'config.tx_extbase.features.consistentTranslationOverlayHandling = 1'
100  );
101  }
102 
103  protected function ‪tearDown()
104  {
105  unset($this->objectManager);
106  unset($this->contentRepository);
107  parent::tearDown();
108  }
109 
110  public function ‪defaultLanguageConfigurationDataProvider(): array
111  {
112  return [
113  [
114  'typoScript' => 'config.sys_language_overlay = 0
115  config.sys_language_mode =',
116  ],
117  [
118  'typoScript' => 'config.sys_language_overlay = 0
119  config.sys_language_mode = content_fallback',
120  ],
121  [
122  'typoScript' => 'config.sys_language_overlay = 0
123  config.sys_language_mode = content_fallback;1,0',
124  ],
125  [
126  'typoScript' => 'config.sys_language_overlay = 0
127  config.sys_language_mode = strict',
128  ],
129  [
130  'typoScript' => 'config.sys_language_overlay = 0
131  config.sys_language_mode = ignore',
132  ],
133  [
134  'typoScript' => 'config.sys_language_overlay = 1
135  config.sys_language_mode =',
136  ],
137  [
138  'typoScript' => 'config.sys_language_overlay = 1
139  config.sys_language_mode = content_fallback',
140  ],
141  [
142  'typoScript' => 'config.sys_language_overlay = 1
143  config.sys_language_mode = content_fallback;1,0',
144  ],
145  [
146  'typoScript' => 'config.sys_language_overlay = 1
147  config.sys_language_mode = strict',
148  ],
149  [
150  'typoScript' => 'config.sys_language_overlay = 1
151  config.sys_language_mode = ignore',
152  ],
153  [
154  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
155  config.sys_language_mode =',
156  ],
157  [
158  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
159  config.sys_language_mode = content_fallback',
160  ],
161  [
162  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
163  config.sys_language_mode = content_fallback;1,0',
164  ],
165  [
166  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
167  config.sys_language_mode = strict',
168  ],
169  [
170  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
171  config.sys_language_mode = ignore',
172  ],
173  ];
174  }
175 
185  public function ‪onlyEnglishContentIsRenderedForDefaultLanguage(string $typoScript)
186  {
187  $this->addTypoScriptToTemplateRecord(1, $typoScript);
188 
189  $frontendResponse = $this->getFrontendResponse(self::VALUE_PageId, 0);
190  $responseSections = $frontendResponse->getResponseSections('Extbase:list()');
191  $visibleHeaders = ['Regular Element #1', 'Regular Element #2', 'Regular Element #3'];
192  $this->assertThat(
193  $responseSections,
195  ->setTable(self::TABLE_Content)
196  ->setField('header')
197  ->setValues(...$visibleHeaders)
198  );
199  $this->assertThat(
200  $responseSections,
202  ->setTable(self::TABLE_Content)
203  ->setField('header')
204  ->setValues(...$this->‪getNonVisibleHeaders($visibleHeaders))
205  );
206 
207  //assert FAL relations
208  $visibleFiles = ['T3BOARD'];
209  $this->assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
210  ->setRecordIdentifier(self::TABLE_Content . ':297')->setRecordField('image')
211  ->setTable('sys_file_reference')->setField('title')->setValues(...$visibleFiles));
212 
213  $this->assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
214  ->setRecordIdentifier(self::TABLE_Content . ':297')->setRecordField('image')
215  ->setTable('sys_file_reference')->setField('title')->setValues(...$this->‪getNonVisibleFileTitles($visibleFiles)));
216 
217  $visibleFiles = ['Kasper2'];
218  $this->assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
219  ->setRecordIdentifier(self::TABLE_Content . ':298')->setRecordField('image')
220  ->setTable('sys_file_reference')->setField('title')->setValues(...$visibleFiles));
221 
222  $this->assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
223  ->setRecordIdentifier(self::TABLE_Content . ':298')->setRecordField('image')
224  ->setTable('sys_file_reference')->setField('title')->setValues(...$this->‪getNonVisibleFileTitles($visibleFiles)));
225 
226  //assert Categories
227  $visibleCategories = ['Category 1', 'Category 3 - not translated'];
228  $this->assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
229  ->setRecordIdentifier(self::TABLE_Content . ':297')->setRecordField('categories')
230  ->setTable('sys_category')->setField('title')->setValues(...$visibleCategories));
231 
232  $this->assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
233  ->setRecordIdentifier(self::TABLE_Content . ':297')->setRecordField('categories')
234  ->setTable('sys_category')->setField('title')->setValues(...$this->‪getNonVisibleCategoryTitles($visibleCategories)));
235  }
236 
242  public function ‪dutchDataProvider(): array
243  {
244  //Expected behaviour:
245  //Page is translated to Dutch, so changing sys_language_mode does NOT change the results
246  //Page title is always [DK]Page, and both sys_language_content and sys_language_uid are always 1
247  return [
248  [
249  'typoScript' => 'config.sys_language_overlay = 0
250  config.sys_language_mode =',
251  'visibleRecords' => [
252  300 => [
253  'header' => '[Translate to Dansk:] Regular Element #3',
254  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
255  ],
256  301 => [
257  'header' => '[Translate to Dansk:] Regular Element #1',
258  'image' => [],
259  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
260  ],
261  303 => [
262  'header' => '[DK] Without default language',
263  'image' => ['[T3BOARD] Image added to DK element without default language']
264  ],
265  308 => [
266  'header' => '[DK] UnHidden Element #4',
267  'image' => []
268  ],
269  ],
270  ],
271  [
272  'typoScript' => 'config.sys_language_overlay = 0
273  config.sys_language_mode = content_fallback',
274  'visibleRecords' => [
275  300 => [
276  'header' => '[Translate to Dansk:] Regular Element #3',
277  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
278  ],
279  301 => [
280  'header' => '[Translate to Dansk:] Regular Element #1',
281  'image' => [],
282  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
283  ],
284  303 => [
285  'header' => '[DK] Without default language',
286  'image' => ['[T3BOARD] Image added to DK element without default language']
287  ],
288  308 => [
289  'header' => '[DK] UnHidden Element #4',
290  'image' => []
291  ],
292  ],
293  ],
294  [
295  'typoScript' => 'config.sys_language_overlay = 0
296  config.sys_language_mode = content_fallback;1,0',
297  'visibleRecords' => [
298  300 => [
299  'header' => '[Translate to Dansk:] Regular Element #3',
300  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
301  ],
302  301 => [
303  'header' => '[Translate to Dansk:] Regular Element #1',
304  'image' => [],
305  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
306  ],
307  303 => [
308  'header' => '[DK] Without default language',
309  'image' => ['[T3BOARD] Image added to DK element without default language']
310  ],
311  308 => [
312  'header' => '[DK] UnHidden Element #4',
313  'image' => []
314  ],
315  ],
316  ],
317  [
318  'typoScript' => 'config.sys_language_overlay = 0
319  config.sys_language_mode = strict',
320  'visibleRecords' => [
321  300 => [
322  'header' => '[Translate to Dansk:] Regular Element #3',
323  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
324  ],
325  301 => [
326  'header' => '[Translate to Dansk:] Regular Element #1',
327  'image' => [],
328  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
329  ],
330  303 => [
331  'header' => '[DK] Without default language',
332  'image' => ['[T3BOARD] Image added to DK element without default language']
333  ],
334  308 => [
335  'header' => '[DK] UnHidden Element #4',
336  'image' => []
337  ],
338  ],
339  ],
340  [
341  'typoScript' => 'config.sys_language_overlay = 0
342  config.sys_language_mode = ignore',
343  'visibleRecords' => [
344  300 => [
345  'header' => '[Translate to Dansk:] Regular Element #3',
346  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
347  ],
348  301 => [
349  'header' => '[Translate to Dansk:] Regular Element #1',
350  'image' => [],
351  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
352  ],
353  303 => [
354  'header' => '[DK] Without default language',
355  'image' => ['[T3BOARD] Image added to DK element without default language']
356  ],
357  308 => [
358  'header' => '[DK] UnHidden Element #4',
359  'image' => []
360  ],
361  ],
362  ],
363  5 => [
364  'typoScript' => 'config.sys_language_overlay = 1
365  config.sys_language_mode =',
366  'visibleRecords' => [
367  297 => [
368  'header' => '[Translate to Dansk:] Regular Element #1',
369  'image' => [],
370  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
371  ],
372  298 => [
373  'header' => 'Regular Element #2',
374  'image' => ['Kasper2'],
375  ],
376  299 => [
377  'header' => '[Translate to Dansk:] Regular Element #3',
378  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
379  ],
380  ],
381  ],
382  // Expected behaviour:
383  // Not translated element #2 is shown because sys_language_overlay = 1 (with sys_language_overlay = hideNonTranslated, it would be hidden)
384  [
385  'typoScript' => 'config.sys_language_overlay = 1
386  config.sys_language_mode = content_fallback',
387  'visibleRecords' => [
388  297 => [
389  'header' => '[Translate to Dansk:] Regular Element #1',
390  'image' => [],
391  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
392  ],
393  298 => [
394  'header' => 'Regular Element #2',
395  'image' => ['Kasper2'],
396  ],
397  299 => [
398  'header' => '[Translate to Dansk:] Regular Element #3',
399  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
400  ],
401  ],
402  ],
403  // Expected behaviour:
404  // Same as config.sys_language_mode = content_fallback because we're requesting language 1, so no additional fallback possible
405  [
406  'typoScript' => 'config.sys_language_overlay = 1
407  config.sys_language_mode = content_fallback;1,0',
408  'visibleRecords' => [
409  297 => [
410  'header' => '[Translate to Dansk:] Regular Element #1',
411  'image' => [],
412  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
413  ],
414  298 => [
415  'header' => 'Regular Element #2',
416  'image' => ['Kasper2'],
417  ],
418  299 => [
419  'header' => '[Translate to Dansk:] Regular Element #3',
420  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
421  ],
422  ],
423  ],
424  [
425  'typoScript' => 'config.sys_language_overlay = 1
426  config.sys_language_mode = strict',
427  'visibleRecords' => [
428  297 => [
429  'header' => '[Translate to Dansk:] Regular Element #1',
430  'image' => [],
431  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
432  ],
433  298 => [
434  'header' => 'Regular Element #2',
435  'image' => ['Kasper2'],
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  ],
443  [
444  'typoScript' => 'config.sys_language_overlay = 1
445  config.sys_language_mode = ignore',
446  'visibleRecords' => [
447  297 => [
448  'header' => '[Translate to Dansk:] Regular Element #1',
449  'image' => [],
450  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
451  ],
452  298 => [
453  'header' => 'Regular Element #2',
454  'image' => ['Kasper2'],
455  ],
456  299 => [
457  'header' => '[Translate to Dansk:] Regular Element #3',
458  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
459  ],
460  ],
461  ],
462  // Expected behaviour:
463  // Non translated default language elements are not shown, because of hideNonTranslated.
464  10 => [
465  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
466  config.sys_language_mode =',
467  'visibleRecords' => [
468  297 => [
469  'header' => '[Translate to Dansk:] Regular Element #1',
470  'image' => [],
471  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
472  ],
473  299 => [
474  'header' => '[Translate to Dansk:] Regular Element #3',
475  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
476  ],
477  ],
478  ],
479  [
480  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
481  config.sys_language_mode = content_fallback',
482  'visibleRecords' => [
483  297 => [
484  'header' => '[Translate to Dansk:] Regular Element #1',
485  'image' => [],
486  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
487  ],
488  299 => [
489  'header' => '[Translate to Dansk:] Regular Element #3',
490  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
491  ],
492  ],
493  ],
494  [
495  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
496  config.sys_language_mode = content_fallback;1,0',
497  'visibleRecords' => [
498  297 => [
499  'header' => '[Translate to Dansk:] Regular Element #1',
500  'image' => [],
501  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
502  ],
503  299 => [
504  'header' => '[Translate to Dansk:] Regular Element #3',
505  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
506  ],
507  ],
508  ],
509  // Expected behaviour: Setting sys_language_mode = strict has the same effect as previous data sets,
510  // because the translation of the page exists
511  // This is not true in Extbase unfortunately. As visible here: sys_language_mode = strict, works like overlay = 0 in TypoScript rendering.
512  [
513  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
514  config.sys_language_mode = strict',
515  'visibleRecords' => [
516  297 => [
517  'header' => '[Translate to Dansk:] Regular Element #1',
518  'image' => [],
519  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
520  ],
521  299 => [
522  'header' => '[Translate to Dansk:] Regular Element #3',
523  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
524  ],
525  ],
526  ],
527  [
528  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
529  config.sys_language_mode = ignore',
530  'visibleRecords' => [
531  297 => [
532  'header' => '[Translate to Dansk:] Regular Element #1',
533  'image' => [],
534  'categories' => ['[Translate to Dansk:] Category 1', 'Category 4'],
535  ],
536  299 => [
537  'header' => '[Translate to Dansk:] Regular Element #3',
538  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
539  ],
540  ],
541  ],
542  ];
543  }
544 
552  public function ‪renderingOfDutchLanguage(string $typoScript, array $visibleRecords)
553  {
554  $this->addTypoScriptToTemplateRecord(1, $typoScript);
555  $frontendResponse = $this->getFrontendResponse(self::VALUE_PageId, 1);
556  $responseSections = $frontendResponse->getResponseSections('Extbase:list()');
557  $visibleHeaders = array_map(function ($element) {
558  return $element['header'];
559  }, $visibleRecords);
560 
561  $this->assertThat(
562  $responseSections,
564  ->setTable(self::TABLE_Content)
565  ->setField('header')
566  ->setValues(...$visibleHeaders)
567  );
568  $this->assertThat(
569  $responseSections,
571  ->setTable(self::TABLE_Content)
572  ->setField('header')
573  ->setValues(...$this->‪getNonVisibleHeaders($visibleHeaders))
574  );
575 
576  foreach ($visibleRecords as $ttContentUid => $properties) {
577  $visibleFileTitles = $properties['image'];
578  if (!empty($visibleFileTitles)) {
579  $this->assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
580  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
581  ->setTable('sys_file_reference')->setField('title')->setValues(...$visibleFileTitles));
582  }
583  $this->assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
584  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
585  ->setTable('sys_file_reference')->setField('title')->setValues(...$this->‪getNonVisibleFileTitles($visibleFileTitles)));
586 
587  $visibleCategoryTitles = $properties['categories'] ?? [];
588  if (!empty($visibleCategoryTitles)) {
589  $this->assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
590  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('categories')
591  ->setTable('sys_category')->setField('title')->setValues(...$visibleCategoryTitles));
592  }
593  $this->assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
594  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('categories')
595  ->setTable('sys_category')->setField('title')->setValues(...$this->‪getNonVisibleCategoryTitles($visibleCategoryTitles)));
596  }
597  }
598 
599  public function ‪contentOnNonTranslatedPageDataProvider(): array
600  {
601  //Expected behaviour:
602  //the page is NOT translated so setting sys_language_mode to different values changes the results
603  //- setting sys_language_mode to empty value makes TYPO3 return default language records
604  //- setting it to strict throws 404, independently from other settings
605  //Setting config.sys_language_overlay = 0
606  return [
607  [
608  'typoScript' => 'config.sys_language_overlay = 0
609  config.sys_language_mode =',
610  'visibleRecords' => [
611  297 => [
612  'header' => 'Regular Element #1',
613  'image' => ['T3BOARD'],
614  ],
615  298 => [
616  'header' => 'Regular Element #2',
617  'image' => ['Kasper2'],
618  ],
619  299 => [
620  'header' => 'Regular Element #3',
621  'image' => ['Kasper'],
622  ],
623  ],
624  ],
625  [
626  'typoScript' => 'config.sys_language_overlay = 0
627  config.sys_language_mode = content_fallback',
628  'visibleRecords' => [
629  297 => [
630  'header' => 'Regular Element #1',
631  'image' => ['T3BOARD'],
632  ],
633  298 => [
634  'header' => 'Regular Element #2',
635  'image' => ['Kasper2'],
636  ],
637  299 => [
638  'header' => 'Regular Element #3',
639  'image' => ['Kasper'],
640  ],
641  ],
642  ],
643  [
644  'typoScript' => 'config.sys_language_overlay = 0
645  config.sys_language_mode = content_fallback;1,0',
646  'visibleRecords' => [
647  300 => [
648  'header' => '[Translate to Dansk:] Regular Element #3',
649  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
650  ],
651  301 => [
652  'header' => '[Translate to Dansk:] Regular Element #1',
653  'image' => [],
654  ],
655  303 => [
656  'header' => '[DK] Without default language',
657  'image' => ['[T3BOARD] Image added to DK element without default language'],
658  ],
659  308 => [
660  'header' => '[DK] UnHidden Element #4',
661  'image' => [],
662  ],
663  ],
664  ],
665  [
666  'typoScript' => 'config.sys_language_overlay = 0
667  config.sys_language_mode = strict',
668  'visibleRecords' => [],
669  'statusCode' => 404,
670  ],
671  [
672  'typoScript' => 'config.sys_language_overlay = 0
673  config.sys_language_mode = ignore',
674  'visibleRecords' => [
675  302 => [
676  'header' => '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
677  'image' => ['[T3BOARD] image translated to DE from DK'],
678  ],
679  304 => [
680  'header' => '[DE] Without default language',
681  'image' => [],
682  ],
683  ],
684  ],
685  5 => [
686  'typoScript' => 'config.sys_language_overlay = 1
687  config.sys_language_mode =',
688  'visibleRecords' => [
689  297 => [
690  'header' => 'Regular Element #1',
691  'image' => ['T3BOARD'],
692  ],
693  298 => [
694  'header' => 'Regular Element #2',
695  'image' => ['Kasper2'],
696  ],
697  299 => [
698  'header' => 'Regular Element #3',
699  'image' => ['Kasper'],
700  ],
701  ],
702  ],
703  //falling back to default language
704  [
705  'typoScript' => 'config.sys_language_overlay = 1
706  config.sys_language_mode = content_fallback',
707  'visibleRecords' => [
708  297 => [
709  'header' => 'Regular Element #1',
710  'image' => ['T3BOARD'],
711  ],
712  298 => [
713  'header' => 'Regular Element #2',
714  'image' => ['Kasper2'],
715  ],
716  299 => [
717  'header' => 'Regular Element #3',
718  'image' => ['Kasper'],
719  ],
720  ],
721  ],
722  //Dutch elements are shown because of the content fallback 1,0 - first Dutch, then default language
723  //note that '[DK] Without default language' is NOT shown - due to overlays (fetch default language and overlay it with translations)
724  [
725  'typoScript' => 'config.sys_language_overlay = 1
726  config.sys_language_mode = content_fallback;1,0',
727  'visibleRecords' => [
728  297 => [
729  'header' => '[Translate to Dansk:] Regular Element #1',
730  'image' => [],
731  ],
732  298 => [
733  'header' => 'Regular Element #2',
734  'image' => ['Kasper2'],
735  ],
736  299 => [
737  'header' => '[Translate to Dansk:] Regular Element #3',
738  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
739  ],
740  ],
741  ],
742  [
743  'typoScript' => 'config.sys_language_overlay = 1
744  config.sys_language_mode = strict',
745  'visibleRecords' => [],
746  'statusCode' => 404
747  ],
748  [
749  'typoScript' => 'config.sys_language_overlay = 1
750  config.sys_language_mode = ignore',
751  'visibleRecords' => [
752  297 => [
753  'header' => '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
754  'image' => ['[T3BOARD] image translated to DE from DK'],
755  ],
756  298 => [
757  'header' => 'Regular Element #2',
758  'image' => ['Kasper2'],
759  ],
760  299 => [
761  'header' => 'Regular Element #3',
762  'image' => ['Kasper'],
763  ],
764  ],
765  ],
766  10 => [
767  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
768  config.sys_language_mode =',
769  'visibleRecords' => [
770  297 => [
771  'header' => 'Regular Element #1',
772  'image' => ['T3BOARD'],
773  ],
774  298 => [
775  'header' => 'Regular Element #2',
776  'image' => ['Kasper2'],
777  ],
778  299 => [
779  'header' => 'Regular Element #3',
780  'image' => ['Kasper'],
781  ],
782  ],
783  ],
784  [
785  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
786  config.sys_language_mode = content_fallback',
787  'visibleRecords' => [
788  297 => [
789  'header' => 'Regular Element #1',
790  'image' => ['T3BOARD'],
791  ],
792  298 => [
793  'header' => 'Regular Element #2',
794  'image' => ['Kasper2'],
795  ],
796  299 => [
797  'header' => 'Regular Element #3',
798  'image' => ['Kasper'],
799  ],
800  ],
801  ],
802  [
803  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
804  config.sys_language_mode = content_fallback;1,0',
805  'visibleRecords' => [
806  297 => [
807  'header' => '[Translate to Dansk:] Regular Element #1',
808  'image' => [],
809  ],
810  299 => [
811  'header' => '[Translate to Dansk:] Regular Element #3',
812  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
813  ],
814  ],
815  ],
816  [
817  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
818  config.sys_language_mode = strict',
819  'visibleRecords' => [],
820  'statusCode' => 404,
821  ],
822  [
823  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
824  config.sys_language_mode = ignore',
825  'visibleRecords' => [
826  297 => [
827  'header' => '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
828  'image' => ['[T3BOARD] image translated to DE from DK'],
829  ],
830  ],
831  ],
832  ];
833  }
834 
845  public function ‪contentOnNonTranslatedPageGerman(string $typoScript, array $visibleRecords, int $statusCode = 200)
846  {
847  $this->addTypoScriptToTemplateRecord(1, $typoScript);
848  $visibleHeaders = array_column($visibleRecords, 'header');
849 
850  $response = $this->executeFrontendRequest(
851  (new InternalRequest())
852  ->withPageId(self::VALUE_PageId)
853  ->withLanguageId(2)
854  );
855 
856  if ($statusCode === 200) {
857  $responseSections = ResponseContent::fromString((string)$response->getBody())
858  ->getSections('Extbase:list()');
859  $this->assertThat(
860  $responseSections,
862  ->setTable(self::TABLE_Content)
863  ->setField('header')
864  ->setValues(...$visibleHeaders)
865  );
866  $this->assertThat(
867  $responseSections,
869  ->setTable(self::TABLE_Content)
870  ->setField('header')
871  ->setValues(...$this->‪getNonVisibleHeaders($visibleHeaders))
872  );
873 
874  foreach ($visibleRecords as $ttContentUid => $properties) {
875  $visibleFileTitles = $properties['image'];
876  if (!empty($visibleFileTitles)) {
877  $this->assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
878  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
879  ->setTable('sys_file_reference')->setField('title')->setValues(...$visibleFileTitles));
880  }
881  $this->assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
882  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
883  ->setTable('sys_file_reference')->setField('title')->setValues(...$this->‪getNonVisibleFileTitles($visibleFileTitles)));
884  }
885  }
886 
887  $this->assertEquals($statusCode, $response->getStatusCode());
888  }
889 
890  public function ‪contentOnPartiallyTranslatedPageDataProvider(): array
891  {
892 
893  //Expected behaviour:
894  //Setting sys_language_mode to different values doesn't influence the result as the requested page is translated to Polish,
895  //Page title is always [PL]Page, and both sys_language_content and sys_language_uid are always 3
896  return [
897  [
898  'typoScript' => 'config.sys_language_overlay = 0
899  config.sys_language_mode =',
900  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
901  ],
902  [
903  'typoScript' => 'config.sys_language_overlay = 0
904  config.sys_language_mode = content_fallback',
905  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
906  ],
907  [
908  'typoScript' => 'config.sys_language_overlay = 0
909  config.sys_language_mode = content_fallback;1,0',
910  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
911  ],
912  [
913  'typoScript' => 'config.sys_language_overlay = 0
914  config.sys_language_mode = strict',
915  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
916  ],
917  [
918  'typoScript' => 'config.sys_language_overlay = 0
919  config.sys_language_mode = ignore',
920  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
921  ],
922  5 => [
923  'typoScript' => 'config.sys_language_overlay = 1
924  config.sys_language_mode =',
925  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
926  ],
927  // Expected behaviour:
928  // Not translated element #2 is shown because sys_language_overlay = 1 (with sys_language_overlay = hideNonTranslated, it would be hidden)
929  [
930  'typoScript' => 'config.sys_language_overlay = 1
931  config.sys_language_mode = content_fallback',
932  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
933  ],
934  // Expected behaviour:
935  // 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
936  // but on page level - and this page is translated to Polish, so no fallback is happening
937  [
938  'typoScript' => 'config.sys_language_overlay = 1
939  config.sys_language_mode = content_fallback;1,0',
940  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
941  ],
942  [
943  'typoScript' => 'config.sys_language_overlay = 1
944  config.sys_language_mode = strict',
945  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
946  ],
947  [
948  'typoScript' => 'config.sys_language_overlay = 1
949  config.sys_language_mode = ignore',
950  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
951  ],
952  // Expected behaviour:
953  // Non translated default language elements are not shown, because of hideNonTranslated
954  10 => [
955  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
956  config.sys_language_mode =',
957  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1'],
958  ],
959  [
960  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
961  config.sys_language_mode = content_fallback',
962  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1'],
963  ],
964  [
965  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
966  config.sys_language_mode = content_fallback;1,0',
967  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1'],
968  ],
969  [
970  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
971  config.sys_language_mode = strict',
972  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1'],
973  ],
974  [
975  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
976  config.sys_language_mode = ignore',
977  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1'],
978  ]
979  ];
980  }
981 
991  public function ‪contentOnPartiallyTranslatedPage(string $typoScript, array $visibleHeaders)
992  {
993  $this->addTypoScriptToTemplateRecord(1, $typoScript);
994 
995  $frontendResponse = $this->getFrontendResponse(self::VALUE_PageId, 3);
996  $this->assertEquals('success', $frontendResponse->getStatus());
997  $responseSections = $frontendResponse->getResponseSections('Extbase:list()');
998 
999  $this->assertThat(
1000  $responseSections,
1002  ->setTable(self::TABLE_Content)
1003  ->setField('header')
1004  ->setValues(...$visibleHeaders)
1005  );
1006  $this->assertThat(
1007  $responseSections,
1009  ->setTable(self::TABLE_Content)
1010  ->setField('header')
1011  ->setValues(...$this->‪getNonVisibleHeaders($visibleHeaders))
1012  );
1013  }
1021  protected function ‪getNonVisibleHeaders(array $visibleHeaders): array
1022  {
1023  $allElements = [
1024  'Regular Element #1',
1025  'Regular Element #2',
1026  'Regular Element #3',
1027  'Hidden Element #4',
1028  '[Translate to Dansk:] Regular Element #1',
1029  '[Translate to Dansk:] Regular Element #3',
1030  '[DK] Without default language',
1031  '[DK] UnHidden Element #4',
1032  '[DE] Without default language',
1033  '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
1034  '[Translate to Polski:] Regular Element #1',
1035  '[PL] Without default language',
1036  '[PL] Hidden Regular Element #2'
1037  ];
1038  return array_diff($allElements, $visibleHeaders);
1039  }
1047  protected function ‪getNonVisibleFileTitles(array $visibleTitles): array
1048  {
1049  $allElements = [
1050  'T3BOARD',
1051  'Kasper',
1052  '[Kasper] Image translated to Dansk',
1053  '[T3BOARD] Image added in Dansk (without parent)',
1054  '[T3BOARD] Image added to DK element without default language',
1055  '[T3BOARD] image translated to DE from DK',
1056  'Kasper2'
1057  ];
1058  return array_diff($allElements, $visibleTitles);
1059  }
1067  protected function ‪getNonVisibleCategoryTitles(array $visibleTitles): array
1068  {
1069  $allElements = [
1070  'Category 1',
1071  '[Translate to Dansk:] Category 1',
1072  'Category 3 - not translated',
1073  'Category 4',
1074  ];
1075  return array_diff($allElements, $visibleTitles);
1076  }
1077 }
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\$configurationToUseInTestInstance
‪array $configurationToUseInTestInstance
Definition: TranslatedContentTest.php:64
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\VALUE_PageId
‪const VALUE_PageId
Definition: TranslatedContentTest.php:35
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:174
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\tearDown
‪tearDown()
Definition: TranslatedContentTest.php:96
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:190
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\TABLE_Content
‪const TABLE_Content
Definition: TranslatedContentTest.php:36
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\dutchDataProvider
‪array dutchDataProvider()
Definition: TranslatedContentTest.php:235
‪TYPO3
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: TranslatedContentTest.php:49
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\contentOnPartiallyTranslatedPage
‪contentOnPartiallyTranslatedPage(string $typoScript, array $visibleHeaders)
Definition: TranslatedContentTest.php:984
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:198
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\setUp
‪setUp()
Definition: TranslatedContentTest.php:77
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:33
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\$pathsToLinkInTestInstance
‪array $pathsToLinkInTestInstance
Definition: TranslatedContentTest.php:72
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\$objectManager
‪TYPO3 CMS Extbase Object ObjectManagerInterface $objectManager
Definition: TranslatedContentTest.php:53
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\defaultLanguageConfigurationDataProvider
‪defaultLanguageConfigurationDataProvider()
Definition: TranslatedContentTest.php:103
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\getNonVisibleHeaders
‪array getNonVisibleHeaders(array $visibleHeaders)
Definition: TranslatedContentTest.php:1014
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\contentOnNonTranslatedPageDataProvider
‪contentOnNonTranslatedPageDataProvider()
Definition: TranslatedContentTest.php:592
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\onlyEnglishContentIsRenderedForDefaultLanguage
‪onlyEnglishContentIsRenderedForDefaultLanguage(string $typoScript)
Definition: TranslatedContentTest.php:178
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\$scenarioDataSetDirectory
‪string $scenarioDataSetDirectory
Definition: TranslatedContentTest.php:41
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence
Definition: AddTest.php:2
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\$contentRepository
‪ExtbaseTeam BlogExample Domain Repository TtContentRepository $contentRepository
Definition: TranslatedContentTest.php:57
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\getNonVisibleCategoryTitles
‪array getNonVisibleCategoryTitles(array $visibleTitles)
Definition: TranslatedContentTest.php:1060
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\contentOnPartiallyTranslatedPageDataProvider
‪contentOnPartiallyTranslatedPageDataProvider()
Definition: TranslatedContentTest.php:883
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionDoesNotHaveRecordConstraint
‪DoesNotHaveRecordConstraint getRequestSectionDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:182
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\getNonVisibleFileTitles
‪array getNonVisibleFileTitles(array $visibleTitles)
Definition: TranslatedContentTest.php:1040
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\contentOnNonTranslatedPageGerman
‪contentOnNonTranslatedPageGerman(string $typoScript, array $visibleRecords, int $statusCode=200)
Definition: TranslatedContentTest.php:838
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: TranslatedContentTest.php:45
‪ExtbaseTeam
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest
Definition: TranslatedContentTest.php:34
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\TABLE_Pages
‪const TABLE_Pages
Definition: TranslatedContentTest.php:37
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\TranslatedContentTest\renderingOfDutchLanguage
‪renderingOfDutchLanguage(string $typoScript, array $visibleRecords)
Definition: TranslatedContentTest.php:545
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\importScenarioDataSet
‪importScenarioDataSet($dataSetName)
Definition: AbstractDataHandlerActionTestCase.php:117