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