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