‪TYPO3CMS  9.5
LocalizedSiteContentRenderingTest.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 
99 {
101 
102  const ‪VALUE_PageId = 89;
103  const ‪TABLE_Content = 'tt_content';
104  const ‪TABLE_Pages = 'pages';
105 
109  protected ‪$scenarioDataSetDirectory = 'typo3/sysext/frontend/Tests/Functional/Rendering/DataSet/';
110 
114  protected ‪$coreExtensionsToLoad = ['frontend', 'workspaces'];
115 
119  protected ‪$pathsToLinkInTestInstance = [
120  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/AdditionalConfiguration.php' => 'typo3conf/AdditionalConfiguration.php',
121  'typo3/sysext/frontend/Tests/Functional/Fixtures/Images' => 'fileadmin/user_upload'
122  ];
123 
130  protected ‪$expectedErrorLogEntries = null;
131 
135  protected const ‪LANGUAGE_PRESETS = [
136  'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en_US.UTF8'],
137  'DK' => ['id' => 1, 'title' => 'Dansk', 'locale' => 'dk_DA.UTF8'],
138  'DE' => ['id' => 2, 'title' => 'Deutsch', 'locale' => 'de_DE.UTF8'],
139  'PL' => ['id' => 3, 'title' => 'Polski', 'locale' => 'pl_PL.UTF8'],
140  ];
141 
142  protected function ‪setUp()
143  {
144  parent::setUp();
145 
146  $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/sys_file_storage.xml');
147  $this->‪importScenarioDataSet('LiveDefaultPages');
148  $this->‪importScenarioDataSet('LiveDefaultElements');
149 
150  $this->setUpFrontendRootPage(1, [
151  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript',
152  ]);
153  }
154 
162  {
164  'test',
165  $this->‪buildSiteConfiguration(1, 'https://website.local/'),
166  [
167  $this->‪buildDefaultLanguageConfiguration('EN', '/en/'),
168  $this->‪buildLanguageConfiguration('DK', '/dk/')
169  ],
170  [
171  $this->‪buildErrorHandlingConfiguration('Fluid', [404])
172  ]
173  );
174 
175  $response = $this->executeFrontendRequest(
176  new InternalRequest('https://website.local/en/?id=' . static::VALUE_PageId)
177  );
178  $responseStructure = ResponseContent::fromString((string)$response->getBody());
179 
180  $responseSections = $responseStructure->getSections();
181  $visibleHeaders = ['Regular Element #1', 'Regular Element #2', 'Regular Element #3'];
182  $this->assertThat(
183  $responseSections,
185  ->setTable(self::TABLE_Content)
186  ->setField('header')
187  ->setValues(...$visibleHeaders)
188  );
189  $this->assertThat(
190  $responseSections,
192  ->setTable(self::TABLE_Content)
193  ->setField('header')
194  ->setValues(...$this->‪getNonVisibleHeaders($visibleHeaders))
195  );
196 
197  //assert FAL relations
198  $visibleFiles = ['T3BOARD'];
199  $this->assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
200  ->setRecordIdentifier(self::TABLE_Content . ':297')->setRecordField('image')
201  ->setTable('sys_file_reference')->setField('title')->setValues(...$visibleFiles));
202 
203  $this->assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
204  ->setRecordIdentifier(self::TABLE_Content . ':297')->setRecordField('image')
205  ->setTable('sys_file_reference')->setField('title')->setValues(...$this->‪getNonVisibleFileTitles($visibleFiles)));
206 
207  $visibleFiles = ['Kasper2'];
208  $this->assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
209  ->setRecordIdentifier(self::TABLE_Content . ':298')->setRecordField('image')
210  ->setTable('sys_file_reference')->setField('title')->setValues(...$visibleFiles));
211 
212  $this->assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
213  ->setRecordIdentifier(self::TABLE_Content . ':298')->setRecordField('image')
214  ->setTable('sys_file_reference')->setField('title')->setValues(...$this->‪getNonVisibleFileTitles($visibleFiles)));
215 
216  // Assert language settings and page record title
217  $this->assertEquals('Default language Page', $responseStructure->getScopePath('page/title'));
218  $this->assertEquals(0, $responseStructure->getScopePath('languageInfo/id'), 'languageId does not match');
219  $this->assertEquals(0, $responseStructure->getScopePath('languageInfo/contentId'), 'contentId does not match');
220  $this->assertEquals('strict', $responseStructure->getScopePath('languageInfo/fallbackType'), 'fallbackType does not match');
221  $this->assertEquals('pageNotFound', $responseStructure->getScopePath('languageInfo/fallbackChain'), 'fallbackChain does not match');
222  $this->assertEquals('includeFloating', $responseStructure->getScopePath('languageInfo/overlayType'), 'language overlayType does not match');
223  }
224 
230  public function ‪dutchDataProvider(): array
231  {
232  return [
233  [
234  // Only records with language=1 are shown
235  'languageConfiguration' => [
236  'fallbackType' => 'free'
237  ],
238  'visibleRecords' => [
239  300 => [
240  'header' => '[Translate to Dansk:] Regular Element #3',
241  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
242  ],
243  301 => [
244  'header' => '[Translate to Dansk:] Regular Element #1',
245  'image' => [],
246  ],
247  303 => [
248  'header' => '[DK] Without default language',
249  'image' => ['[T3BOARD] Image added to DK element without default language']
250  ],
251  308 => [
252  'header' => '[DK] UnHidden Element #4',
253  'image' => []
254  ],
255  ],
256  'fallbackType' => 'free',
257  'fallbackChain' => 'pageNotFound',
258  'overlayMode' => 'off',
259  ],
260  // Expected behaviour:
261  // Not translated element #2 is shown because "fallback" is enabled, which defaults to L=0 elements
262  [
263  'languageConfiguration' => [
264  'fallbackType' => 'fallback'
265  ],
266  'visibleRecords' => [
267  297 => [
268  'header' => '[Translate to Dansk:] Regular Element #1',
269  'image' => [],
270  ],
271  298 => [
272  'header' => 'Regular Element #2',
273  'image' => ['Kasper2'],
274  ],
275  299 => [
276  'header' => '[Translate to Dansk:] Regular Element #3',
277  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
278  ],
279  ],
280  'fallbackType' => 'fallback',
281  'fallbackChain' => 'pageNotFound',
282  'overlayMode' => 'mixed',
283  ],
284  // Expected behaviour:
285  // Non translated default language elements are not shown, but the results include the records without default language as well
286  [
287  'languageConfiguration' => [
288  'fallbackType' => 'strict'
289  ],
290  'visibleRecords' => [
291  297 => [
292  'header' => '[Translate to Dansk:] Regular Element #1',
293  'image' => [],
294  ],
295  299 => [
296  'header' => '[Translate to Dansk:] Regular Element #3',
297  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
298  ],
299  303 => [
300  'header' => '[DK] Without default language',
301  'image' => ['[T3BOARD] Image added to DK element without default language'],
302  ],
303  ],
304  'fallbackType' => 'strict',
305  'fallbackChain' => 'pageNotFound',
306  'overlayMode' => 'includeFloating',
307  ],
308  ];
309  }
310 
323  public function ‪renderingOfDutchLanguage(array $languageConfiguration, array $visibleRecords, string $fallbackType, string $fallbackChain, string $overlayType)
324  {
326  'test',
327  $this->‪buildSiteConfiguration(1, 'https://website.local/'),
328  [
329  $this->‪buildDefaultLanguageConfiguration('EN', '/en/'),
330  $this->‪buildLanguageConfiguration('DK', '/dk/', $languageConfiguration['fallbackChain'] ?? [], $languageConfiguration['fallbackType'])
331  ],
332  [
333  $this->‪buildErrorHandlingConfiguration('Fluid', [404])
334  ]
335  );
336 
337  $response = $this->executeFrontendRequest(
338  new InternalRequest('https://website.local/dk/?id=' . static::VALUE_PageId)
339  );
340  $responseStructure = ResponseContent::fromString((string)$response->getBody());
341  $responseSections = $responseStructure->getSections();
342  $visibleHeaders = array_map(function ($element) {
343  return $element['header'];
344  }, $visibleRecords);
345 
346  $this->assertThat(
347  $responseSections,
349  ->setTable(self::TABLE_Content)
350  ->setField('header')
351  ->setValues(...$visibleHeaders)
352  );
353  $this->assertThat(
354  $responseSections,
356  ->setTable(self::TABLE_Content)
357  ->setField('header')
358  ->setValues(...$this->‪getNonVisibleHeaders($visibleHeaders))
359  );
360 
361  foreach ($visibleRecords as $ttContentUid => $properties) {
362  $visibleFileTitles = $properties['image'];
363  if (!empty($visibleFileTitles)) {
364  $this->assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
365  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
366  ->setTable('sys_file_reference')->setField('title')->setValues(...$visibleFileTitles));
367  }
368  $this->assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
369  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
370  ->setTable('sys_file_reference')->setField('title')->setValues(...$this->‪getNonVisibleFileTitles($visibleFileTitles)));
371  }
372 
373  $this->assertEquals('[DK]Page', $responseStructure->getScopePath('page/title'));
374  $this->assertEquals(1, $responseStructure->getScopePath('languageInfo/id'), 'languageId does not match');
375  $this->assertEquals(1, $responseStructure->getScopePath('languageInfo/contentId'), 'contentId does not match');
376  $this->assertEquals($fallbackType, $responseStructure->getScopePath('languageInfo/fallbackType'), 'fallbackType does not match');
377  $this->assertEquals($fallbackChain, $responseStructure->getScopePath('languageInfo/fallbackChain'), 'fallbackChain does not match');
378  $this->assertEquals($overlayType, $responseStructure->getScopePath('languageInfo/overlayType'), 'language overlayType does not match');
379  }
380 
381  public function ‪contentOnNonTranslatedPageDataProvider(): array
382  {
383  //Expected behaviour:
384  //the page is NOT translated so setting sys_language_mode to different values changes the results
385  //- setting sys_language_mode to empty value makes TYPO3 return default language records
386  //- setting it to strict throws 404, independently from other settings
387  //Setting config.sys_language_overlay = 0
388  return [
389  [
390  'languageConfiguration' => [
391  'fallbackType' => 'free',
392  'fallbackChain' => ['EN']
393  ],
394  'visibleRecords' => [
395  297 => [
396  'header' => 'Regular Element #1',
397  'image' => ['T3BOARD'],
398  ],
399  298 => [
400  'header' => 'Regular Element #2',
401  'image' => ['Kasper2'],
402  ],
403  299 => [
404  'header' => 'Regular Element #3',
405  'image' => ['Kasper'],
406  ],
407  ],
408  'pageTitle' => 'Default language Page',
409  'languageId' => 2,
410  'contentId' => 0,
411  'fallbackType' => 'free',
412  'fallbackChain' => '0,pageNotFound',
413  'overlayMode' => 'off',
414  ],
415  [
416  'languageConfiguration' => [
417  'fallbackType' => 'free',
418  'fallbackChain' => ['EN']
419  ],
420  'visibleRecords' => [
421  297 => [
422  'header' => 'Regular Element #1',
423  'image' => ['T3BOARD'],
424  ],
425  298 => [
426  'header' => 'Regular Element #2',
427  'image' => ['Kasper2'],
428  ],
429  299 => [
430  'header' => 'Regular Element #3',
431  'image' => ['Kasper'],
432  ],
433  ],
434  'pageTitle' => 'Default language Page',
435  'languageId' => 2,
436  'contentId' => 0,
437  'fallbackType' => 'free',
438  'fallbackChain' => '0,pageNotFound',
439  'overlayMode' => 'off',
440  ],
441  [
442  'languageConfiguration' => [
443  'fallbackType' => 'free',
444  'fallbackChain' => ['DK', 'EN']
445  ],
446  'visibleRecords' => [
447  300 => [
448  'header' => '[Translate to Dansk:] Regular Element #3',
449  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
450  ],
451  301 => [
452  'header' => '[Translate to Dansk:] Regular Element #1',
453  'image' => [],
454  ],
455  303 => [
456  'header' => '[DK] Without default language',
457  'image' => ['[T3BOARD] Image added to DK element without default language'],
458  ],
459  308 => [
460  'header' => '[DK] UnHidden Element #4',
461  'image' => [],
462  ],
463  ],
464  'pageTitle' => '[DK]Page',
465  'languageId' => 2,
466  'contentId' => 1,
467  'fallbackType' => 'free',
468  'fallbackChain' => '1,0,pageNotFound',
469  'overlayMode' => 'off',
470  ],
471  [
472  'languageConfiguration' => [
473  'fallbackType' => 'free'
474  ],
475  'visibleRecords' => [],
476  'pageTitle' => '',
477  'languageId' => 2,
478  'contentId' => 2,
479  'fallbackType' => 'free',
480  'fallbackChain' => 'pageNotFound',
481  'overlayMode' => 'off',
482  'statusCode' => 404,
483  ],
484  [
485  'languageConfiguration' => [
486  'fallbackType' => 'fallback',
487  'fallbackChain' => ['EN']
488  ],
489  'visibleRecords' => [
490  297 => [
491  'header' => 'Regular Element #1',
492  'image' => ['T3BOARD'],
493  ],
494  298 => [
495  'header' => 'Regular Element #2',
496  'image' => ['Kasper2'],
497  ],
498  299 => [
499  'header' => 'Regular Element #3',
500  'image' => ['Kasper'],
501  ],
502  ],
503  'pageTitle' => 'Default language Page',
504  'languageId' => 2,
505  'contentId' => 0,
506  'fallbackType' => 'fallback',
507  'fallbackChain' => '0,pageNotFound',
508  'overlayMode' => 'mixed',
509  ],
510  //falling back to default language
511  [
512  'languageConfiguration' => [
513  'fallbackType' => 'fallback',
514  'fallbackChain' => ['EN']
515  ],
516  'visibleRecords' => [
517  297 => [
518  'header' => 'Regular Element #1',
519  'image' => ['T3BOARD'],
520  ],
521  298 => [
522  'header' => 'Regular Element #2',
523  'image' => ['Kasper2'],
524  ],
525  299 => [
526  'header' => 'Regular Element #3',
527  'image' => ['Kasper'],
528  ],
529  ],
530  'pageTitle' => 'Default language Page',
531  'languageId' => 2,
532  'contentId' => 0,
533  'fallbackType' => 'fallback',
534  'fallbackChain' => '0,pageNotFound',
535  'overlayMode' => 'mixed',
536  ],
537  //Dutch elements are shown because of the content fallback 1,0 - first Dutch, then default language
538  //note that '[DK] Without default language' is NOT shown - due to overlays (fetch default language and overlay it with translations)
539  [
540  'languageConfiguration' => [
541  'fallbackType' => 'fallback',
542  'fallbackChain' => ['DK', 'EN']
543  ],
544  'visibleRecords' => [
545  297 => [
546  'header' => '[Translate to Dansk:] Regular Element #1',
547  'image' => [],
548  ],
549  298 => [
550  'header' => 'Regular Element #2',
551  'image' => ['Kasper2'],
552  ],
553  299 => [
554  'header' => '[Translate to Dansk:] Regular Element #3',
555  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
556  ],
557  ],
558  'pageTitle' => '[DK]Page',
559  'languageId' => 2,
560  'contentId' => 1,
561  'fallbackType' => 'fallback',
562  'fallbackChain' => '1,0,pageNotFound',
563  'overlayMode' => 'mixed',
564  ],
565  [
566  'languageConfiguration' => [
567  'fallbackType' => 'fallback',
568  'fallbackChain' => []
569  ],
570  'visibleRecords' => [],
571  'pageTitle' => '',
572  'languageId' => 2,
573  'contentId' => 0,
574  'fallbackType' => 'fallback',
575  'fallbackChain' => 'pageNotFound',
576  'overlayMode' => 'mixed',
577  'statusCode' => 404
578  ],
579  [
580  'languageConfiguration' => [
581  'fallbackType' => 'strict',
582  'fallbackChain' => ['EN']
583  ],
584  'visibleRecords' => [
585  297 => [
586  'header' => 'Regular Element #1',
587  'image' => ['T3BOARD'],
588  ],
589  298 => [
590  'header' => 'Regular Element #2',
591  'image' => ['Kasper2'],
592  ],
593  299 => [
594  'header' => 'Regular Element #3',
595  'image' => ['Kasper'],
596  ],
597  ],
598  'pageTitle' => 'Default language Page',
599  'languageId' => 2,
600  'contentId' => 0,
601  'fallbackType' => 'strict',
602  'fallbackChain' => '0,pageNotFound',
603  'overlayMode' => 'includeFloating',
604  ],
605  [
606  'languageConfiguration' => [
607  'fallbackType' => 'strict',
608  'fallbackChain' => ['DK', 'EN']
609  ],
610  'visibleRecords' => [
611  297 => [
612  'header' => '[Translate to Dansk:] Regular Element #1',
613  'image' => [],
614  ],
615  299 => [
616  'header' => '[Translate to Dansk:] Regular Element #3',
617  'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
618  ],
619  303 => [
620  'header' => '[DK] Without default language',
621  'image' => ['[T3BOARD] Image added to DK element without default language']
622  ],
623  ],
624  'pageTitle' => '[DK]Page',
625  'languageId' => 2,
626  'contentId' => 1,
627  'fallbackType' => 'strict',
628  'fallbackChain' => '1,0,pageNotFound',
629  'overlayMode' => 'includeFloating',
630  ],
631  [
632  'languageConfiguration' => [
633  'fallbackType' => 'strict',
634  'fallbackChain' => []
635  ],
636  'visibleRecords' => [],
637  'pageTitle' => '',
638  'languageId' => 2,
639  'contentId' => 1,
640  'fallbackType' => 'strict',
641  'fallbackChain' => 'pageNotFound',
642  'overlayMode' => 'includeFloating',
643  'statusCode' => 404,
644  ],
645  ];
646  }
647 
664  public function ‪contentOnNonTranslatedPageGerman(array $languageConfiguration, array $visibleRecords, string $pageTitle, int $languageId, int $contentLanguageId, string $fallbackType, string $fallbackChain, string $overlayMode, int $statusCode = 200)
665  {
667  'main',
668  $this->‪buildSiteConfiguration(1, 'https://website.local/'),
669  [
670  $this->‪buildDefaultLanguageConfiguration('EN', '/en/'),
671  $this->‪buildLanguageConfiguration('DK', '/dk/'),
672  $this->‪buildLanguageConfiguration('DE', '/de/', $languageConfiguration['fallbackChain'] ?? [], $languageConfiguration['fallbackType'])
673  ],
674  [
675  $this->‪buildErrorHandlingConfiguration('Fluid', [404])
676  ]
677  );
678 
679  if ($statusCode === 404) {
680  $this->expectExceptionCode(1518472189);
681  $this->expectException(PageNotFoundException::class);
682  }
683  $response = $this->executeFrontendRequest(
684  new InternalRequest('https://website.local/de/?id=' . static::VALUE_PageId)
685  );
686 
687  if ($statusCode === 200) {
688  $visibleHeaders = array_column($visibleRecords, 'header');
689  $responseStructure = ResponseContent::fromString((string)$response->getBody());
690  $responseSections = $responseStructure->getSections();
691 
692  $this->assertThat(
693  $responseSections,
695  ->setTable(self::TABLE_Content)
696  ->setField('header')
697  ->setValues(...$visibleHeaders)
698  );
699  $this->assertThat(
700  $responseSections,
702  ->setTable(self::TABLE_Content)
703  ->setField('header')
704  ->setValues(...$this->‪getNonVisibleHeaders($visibleHeaders))
705  );
706 
707  foreach ($visibleRecords as $ttContentUid => $properties) {
708  $visibleFileTitles = $properties['image'];
709  if (!empty($visibleFileTitles)) {
710  $this->assertThat($responseSections, $this->‪getRequestSectionStructureHasRecordConstraint()
711  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
712  ->setTable('sys_file_reference')->setField('title')->setValues(...$visibleFileTitles));
713  }
714  $this->assertThat($responseSections, $this->‪getRequestSectionStructureDoesNotHaveRecordConstraint()
715  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
716  ->setTable('sys_file_reference')->setField('title')->setValues(...$this->‪getNonVisibleFileTitles($visibleFileTitles)));
717  }
718 
719  $this->assertEquals($pageTitle, $responseStructure->getScopePath('page/title'));
720  $this->assertEquals($languageId, $responseStructure->getScopePath('languageInfo/id'), 'languageId does not match');
721  $this->assertEquals($contentLanguageId, $responseStructure->getScopePath('languageInfo/contentId'), 'contentId does not match');
722  $this->assertEquals($fallbackType, $responseStructure->getScopePath('languageInfo/fallbackType'), 'fallbackType does not match');
723  $this->assertEquals($fallbackChain, $responseStructure->getScopePath('languageInfo/fallbackChain'), 'fallbackChain does not match');
724  $this->assertEquals($overlayMode, $responseStructure->getScopePath('languageInfo/overlayType'), 'language overlayType does not match');
725  }
726  }
727 
728  public function ‪contentOnPartiallyTranslatedPageDataProvider(): array
729  {
730 
731  //Expected behaviour:
732  //Setting sys_language_mode to different values doesn't influence the result as the requested page is translated to Polish,
733  //Page title is always [PL]Page, and both sys_language_content and sys_language_uid are always 3
734  return [
735  [
736  'languageConfiguration' => [
737  'fallbackType' => 'free'
738  ],
739  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
740  'fallbackType' => 'free',
741  'fallbackChain' => 'pageNotFound',
742  'overlayMode' => 'off',
743  ],
744  [
745  'languageConfiguration' => [
746  'fallbackType' => 'free',
747  'fallbackChain' => ['EN']
748  ],
749  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
750  'fallbackType' => 'free',
751  'fallbackChain' => '0,pageNotFound',
752  'overlayMode' => 'off',
753  ],
754  [
755  'languageConfiguration' => [
756  'fallbackType' => 'free',
757  'fallbackChain' => ['DK', 'EN']
758  ],
759  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
760  'fallbackType' => 'free',
761  'fallbackChain' => '1,0,pageNotFound',
762  'overlayMode' => 'off',
763  ],
764  // Expected behaviour:
765  // Not translated element #2 is shown because sys_language_overlay = 1 (with sys_language_overlay = hideNonTranslated, it would be hidden)
766  [
767  'languageConfiguration' => [
768  'fallbackType' => 'fallback',
769  'fallbackChain' => ['EN']
770  ],
771  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
772  'fallbackType' => 'fallback',
773  'fallbackChain' => '0,pageNotFound',
774  'overlayMode' => 'mixed',
775  ],
776  // Expected behaviour:
777  // 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
778  // but on page level - and this page is translated to Polish, so no fallback is happening
779  [
780  'languageConfiguration' => [
781  'fallbackType' => 'fallback',
782  'fallbackChain' => ['DK', 'EN']
783  ],
784  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
785  'fallbackType' => 'fallback',
786  'fallbackChain' => '1,0,pageNotFound',
787  'overlayMode' => 'mixed',
788  ],
789  [
790  'languageConfiguration' => [
791  'fallbackType' => 'fallback',
792  'fallbackChain' => []
793  ],
794  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
795  'fallbackType' => 'fallback',
796  'fallbackChain' => 'pageNotFound',
797  'overlayMode' => 'mixed',
798  ],
799  // Expected behaviour:
800  // Non translated default language elements are not shown, because of hideNonTranslated
801  [
802  'languageConfiguration' => [
803  'fallbackType' => 'strict',
804  'fallbackChain' => ['EN']
805  ],
806  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
807  'fallbackType' => 'strict',
808  'fallbackChain' => '0,pageNotFound',
809  'overlayMode' => 'includeFloating',
810  ],
811  [
812  'languageConfiguration' => [
813  'fallbackType' => 'strict',
814  'fallbackChain' => ['DK', 'EN']
815  ],
816  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
817  'fallbackType' => 'strict',
818  'fallbackChain' => '1,0,pageNotFound',
819  'overlayMode' => 'includeFloating',
820  ],
821  [
822  'languageConfiguration' => [
823  'fallbackType' => 'strict',
824  'fallbackChain' => []
825  ],
826  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
827  'fallbackType' => 'strict',
828  'fallbackChain' => 'pageNotFound',
829  'overlayMode' => 'includeFloating',
830  ],
831  ];
832  }
833 
846  public function ‪contentOnPartiallyTranslatedPage(array $languageConfiguration, array $visibleHeaders, string $fallbackType, string $fallbackChain, string $overlayType)
847  {
849  'test',
850  $this->‪buildSiteConfiguration(1, 'https://website.local/'),
851  [
852  $this->‪buildDefaultLanguageConfiguration('EN', '/en/'),
853  $this->‪buildLanguageConfiguration('DK', '/dk/'),
854  $this->‪buildLanguageConfiguration('PL', '/pl/', $languageConfiguration['fallbackChain'] ?? [], $languageConfiguration['fallbackType'])
855  ],
856  [
857  $this->‪buildErrorHandlingConfiguration('Fluid', [404])
858  ]
859  );
860 
861  $response = $this->executeFrontendRequest(
862  new InternalRequest('https://website.local/pl/?id=' . static::VALUE_PageId)
863  );
864  $responseStructure = ResponseContent::fromString((string)$response->getBody());
865  $responseSections = $responseStructure->getSections();
866 
867  $this->assertEquals(200, $response->getStatusCode());
868 
869  $this->assertThat(
870  $responseSections,
872  ->setTable(self::TABLE_Content)
873  ->setField('header')
874  ->setValues(...$visibleHeaders)
875  );
876  $this->assertThat(
877  $responseSections,
879  ->setTable(self::TABLE_Content)
880  ->setField('header')
881  ->setValues(...$this->‪getNonVisibleHeaders($visibleHeaders))
882  );
883 
884  $this->assertEquals('[PL]Page', $responseStructure->getScopePath('page/title'));
885  $this->assertEquals(3, $responseStructure->getScopePath('languageInfo/id'), 'languageId does not match');
886  $this->assertEquals(3, $responseStructure->getScopePath('languageInfo/contentId'), 'contentId does not match');
887  $this->assertEquals($fallbackType, $responseStructure->getScopePath('languageInfo/fallbackType'), 'fallbackType does not match');
888  $this->assertEquals($fallbackChain, $responseStructure->getScopePath('languageInfo/fallbackChain'), 'fallbackChain does not match');
889  $this->assertEquals($overlayType, $responseStructure->getScopePath('languageInfo/overlayType'), 'language overlayType does not match');
890  }
891 
898  protected function ‪getNonVisibleHeaders(array $visibleHeaders): array
899  {
900  $allElements = [
901  'Regular Element #1',
902  'Regular Element #2',
903  'Regular Element #3',
904  'Hidden Element #4',
905  '[Translate to Dansk:] Regular Element #1',
906  '[Translate to Dansk:] Regular Element #3',
907  '[DK] Without default language',
908  '[DK] UnHidden Element #4',
909  '[DE] Without default language',
910  '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
911  '[Translate to Polski:] Regular Element #1',
912  '[PL] Without default language',
913  '[PL] Hidden Regular Element #2'
914  ];
915  return array_diff($allElements, $visibleHeaders);
916  }
917 
924  protected function ‪getNonVisibleFileTitles(array $visibleTitles): array
925  {
926  $allElements = [
927  'T3BOARD',
928  'Kasper',
929  '[Kasper] Image translated to Dansk',
930  '[T3BOARD] Image added in Dansk (without parent)',
931  '[T3BOARD] Image added to DK element without default language',
932  '[T3BOARD] image translated to DE from DK',
933  'Kasper2',
934  ];
935  return array_diff($allElements, $visibleTitles);
936  }
937 }
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\TABLE_Pages
‪const TABLE_Pages
Definition: LocalizedSiteContentRenderingTest.php:103
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\$expectedErrorLogEntries
‪int null $expectedErrorLogEntries
Definition: LocalizedSiteContentRenderingTest.php:125
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildErrorHandlingConfiguration
‪array buildErrorHandlingConfiguration(string $handler, array $codes)
Definition: SiteBasedTestTrait.php:182
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:174
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureHasRecordConstraint
‪StructureHasRecordConstraint getRequestSectionStructureHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:190
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:34
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildLanguageConfiguration
‪array buildLanguageConfiguration(string $identifier, string $base, array $fallbackIdentifiers=[], string $fallbackType=null)
Definition: SiteBasedTestTrait.php:140
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\$scenarioDataSetDirectory
‪string $scenarioDataSetDirectory
Definition: LocalizedSiteContentRenderingTest.php:107
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:56
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest
Definition: LocalizedSiteContentRenderingTest.php:99
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\$pathsToLinkInTestInstance
‪array $pathsToLinkInTestInstance
Definition: LocalizedSiteContentRenderingTest.php:115
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionStructureDoesNotHaveRecordConstraint
‪StructureDoesNotHaveRecordConstraint getRequestSectionStructureDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:198
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:33
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\contentOnNonTranslatedPageDataProvider
‪contentOnNonTranslatedPageDataProvider()
Definition: LocalizedSiteContentRenderingTest.php:376
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪array buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:122
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\contentOnPartiallyTranslatedPageDataProvider
‪contentOnPartiallyTranslatedPageDataProvider()
Definition: LocalizedSiteContentRenderingTest.php:723
‪TYPO3\CMS\Core\Error\Http\PageNotFoundException
Definition: PageNotFoundException.php:21
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionDoesNotHaveRecordConstraint
‪DoesNotHaveRecordConstraint getRequestSectionDoesNotHaveRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:182
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\$coreExtensionsToLoad
‪string[] $coreExtensionsToLoad
Definition: LocalizedSiteContentRenderingTest.php:111
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\renderingOfDutchLanguage
‪renderingOfDutchLanguage(array $languageConfiguration, array $visibleRecords, string $fallbackType, string $fallbackChain, string $overlayType)
Definition: LocalizedSiteContentRenderingTest.php:318
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\contentOnPartiallyTranslatedPage
‪contentOnPartiallyTranslatedPage(array $languageConfiguration, array $visibleHeaders, string $fallbackType, string $fallbackChain, string $overlayType)
Definition: LocalizedSiteContentRenderingTest.php:841
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\getNonVisibleHeaders
‪array getNonVisibleHeaders(array $visibleHeaders)
Definition: LocalizedSiteContentRenderingTest.php:893
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\LANGUAGE_PRESETS
‪const LANGUAGE_PRESETS
Definition: LocalizedSiteContentRenderingTest.php:130
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\contentOnNonTranslatedPageGerman
‪contentOnNonTranslatedPageGerman(array $languageConfiguration, array $visibleRecords, string $pageTitle, int $languageId, int $contentLanguageId, string $fallbackType, string $fallbackChain, string $overlayMode, int $statusCode=200)
Definition: LocalizedSiteContentRenderingTest.php:659
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\getNonVisibleFileTitles
‪array getNonVisibleFileTitles(array $visibleTitles)
Definition: LocalizedSiteContentRenderingTest.php:919
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪array buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:107
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\onlyEnglishContentIsRenderedForDefaultLanguage
‪onlyEnglishContentIsRenderedForDefaultLanguage()
Definition: LocalizedSiteContentRenderingTest.php:156
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\TABLE_Content
‪const TABLE_Content
Definition: LocalizedSiteContentRenderingTest.php:102
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\dutchDataProvider
‪array dutchDataProvider()
Definition: LocalizedSiteContentRenderingTest.php:225
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering
Definition: LocalizedContentRenderingTest.php:4
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\setUp
‪setUp()
Definition: LocalizedSiteContentRenderingTest.php:137
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\importScenarioDataSet
‪importScenarioDataSet($dataSetName)
Definition: AbstractDataHandlerActionTestCase.php:117
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\LocalizedSiteContentRenderingTest\VALUE_PageId
‪const VALUE_PageId
Definition: LocalizedSiteContentRenderingTest.php:101