[TASK] Tests for rendering tt_content with FAL in Extbase 52/53952/2
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Wed, 6 Sep 2017 07:01:49 +0000 (09:01 +0200)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Thu, 7 Sep 2017 14:29:56 +0000 (16:29 +0200)
Functional tests checking Extbase rendering of tt_content
records with FAL images.

Also fixes two typos in fixture data.

Resolves: #82298
Releases: master, 8.7, 7.6
Change-Id: I2cddf81a99b08df46a7fd03dc0e54b41b10452e5
Reviewed-on: https://review.typo3.org/53921
Reviewed-on: https://review.typo3.org/53952
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example/Classes/Controller/ContentController.php
typo3/sysext/extbase/Tests/Functional/Persistence/TranslatedContentTest.php
typo3/sysext/frontend/Tests/Functional/Rendering/DataSet/LiveDefaultElements.csv
typo3/sysext/frontend/Tests/Functional/Rendering/LocalizedContentRenderingTest.php

index bd22e6e..282ea9c 100644 (file)
@@ -107,6 +107,13 @@ class ContentController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControll
                     $structureItem[$propertyName] = $propertyValue;
                 }
             }
+            //let's flatten the structure and put file reference properties level up, so we can use StructureHasRecordConstraint
+            if ($entity instanceof \TYPO3\CMS\Extbase\Domain\Model\FileReference
+                && isset($structureItem['originalResource'])
+                && $structureItem['originalResource'] instanceof \TYPO3\CMS\Core\Resource\FileReference
+            ) {
+                $structureItem = $structureItem['originalResource']->getProperties();
+            }
             $structure[$identifier] = $structureItem;
         }
 
index 09a348a..ef0edd5 100644 (file)
@@ -166,7 +166,7 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
      *
      * @param string $typoScript
      */
-    public function onlyEnglishContentIsRenderedForDefaultLanguage( $typoScript)
+    public function onlyEnglishContentIsRenderedForDefaultLanguage($typoScript)
     {
         $this->addTypoScriptToTemplateRecord(1, $typoScript);
 
@@ -177,14 +177,33 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
         $constraint = $this->getRequestSectionHasRecordConstraint()
             ->setTable(self::TABLE_Content)
             ->setField('header');
-        call_user_func_array([$constraint, 'setValues'], $visibleHeaders);
-        $this->assertThat($responseSections, $constraint);
+            call_user_func_array([$constraint, 'setValues'],$visibleHeaders);
 
+        $this->assertThat($responseSections, $constraint);
         $constraint = $this->getRequestSectionDoesNotHaveRecordConstraint()
             ->setTable(self::TABLE_Content)
             ->setField('header');
-        call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleHeaders($visibleHeaders));
+            call_user_func_array([$constraint, 'setValues'],$this->getNonVisibleHeaders($visibleHeaders));
         $this->assertThat($responseSections, $constraint);
+
+        //assert FAL relations
+        $visibleRecords = [
+            297  => ['T3BOARD'],
+            298  => ['Kasper'],
+        ];
+        foreach ($visibleRecords as $ttContentUid => $visibleFileTitles) {
+            $constraint = $this->getRequestSectionStructureHasRecordConstraint()
+                ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
+                ->setTable('sys_file_reference')->setField('title');
+            call_user_func_array([$constraint, 'setValues'], $visibleFileTitles);
+            $this->assertThat($responseSections, $constraint);
+
+            $constraint = $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
+                ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
+                ->setTable('sys_file_reference')->setField('title');
+            call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleFileTitles($visibleFileTitles));
+            $this->assertThat($responseSections, $constraint);
+        }
     }
 
     /**
@@ -200,40 +219,185 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
         return [
             [
                 'typoScript' => 'config.sys_language_overlay = 0
-                                config.sys_language_mode =',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language', 'Regular Element #2', '[DK] UnHidden Element #4'],
+                                    config.sys_language_mode =',
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 0
                                 config.sys_language_mode = content_fallback',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language', 'Regular Element #2', '[DK] UnHidden Element #4'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 0
                                 config.sys_language_mode = content_fallback;1,0',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language', 'Regular Element #2', '[DK] UnHidden Element #4'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 0
                                 config.sys_language_mode = strict',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => [],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 0
                                 config.sys_language_mode = ignore',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language', 'Regular Element #2', '[DK] UnHidden Element #4'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
             5 => [
                 'typoScript' => 'config.sys_language_overlay = 1
                                 config.sys_language_mode =',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', 'Regular Element #2', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language', '[DK] UnHidden Element #4'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
 //             Expected behaviour:
 //             Not translated element #2 is shown because sys_language_overlay = 1 (with sys_language_overlay = hideNonTranslated, it would be hidden)
             [
                 'typoScript' => 'config.sys_language_overlay = 1
                                 config.sys_language_mode = content_fallback',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', 'Regular Element #2', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language', '[DK] UnHidden Element #4'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
 //             Expected behaviour:
 //             Same as config.sys_language_mode = content_fallback because we're requesting language 1, so no additional fallback possible
@@ -241,45 +405,201 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
             [
                 'typoScript' => 'config.sys_language_overlay = 1
                                 config.sys_language_mode = content_fallback;1,0',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', 'Regular Element #2', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language', '[DK] UnHidden Element #4'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 1
                                 config.sys_language_mode = strict',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => [],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 1
                                 config.sys_language_mode = ignore',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', 'Regular Element #2', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language', '[DK] UnHidden Element #4'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
 //             Expected behaviour:
 //             Non translated default language elements are not shown, because of hideNonTranslated
             10 => [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
                                 config.sys_language_mode =',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', 'Regular Element #2', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language', '[DK] UnHidden Element #4'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
                                 config.sys_language_mode = content_fallback',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', 'Regular Element #2', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language', '[DK] UnHidden Element #4'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
                                 config.sys_language_mode = content_fallback;1,0',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', 'Regular Element #2', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language', '[DK] UnHidden Element #4'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
 //            Setting sys_language_mode = strict has the same effect as previous data sets, because the translation of the page exists
             [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
                                 config.sys_language_mode = strict',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => [],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
                                 config.sys_language_mode = ignore',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', 'Regular Element #2', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language', '[DK] UnHidden Element #4'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
         ];
     }
@@ -289,13 +609,16 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
      * @dataProvider dutchDataProvider
      *
      * @param string $typoScript
-     * @param array $visibleHeaders
+     * @param array $visibleRecords
      */
-    public function renderingOfDutchLanguage($typoScript, array $visibleHeaders)
+    public function renderingOfDutchLanguage($typoScript, array $visibleRecords)
     {
         $this->addTypoScriptToTemplateRecord(1, $typoScript);
         $frontendResponse = $this->getFrontendResponse(self::VALUE_PageId, 1);
         $responseSections = $frontendResponse->getResponseSections('Extbase:list()');
+        $visibleHeaders = array_map(function ($element) {
+            return $element['header'];
+        }, $visibleRecords);
         $constraint = $this->getRequestSectionHasRecordConstraint()
             ->setTable(self::TABLE_Content)
             ->setField('header');
@@ -307,6 +630,22 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
             ->setField('header');
         call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleHeaders($visibleHeaders));
         $this->assertThat($responseSections, $constraint);
+
+        foreach ($visibleRecords as $ttContentUid => $properties) {
+            $visibleFileTitles = $properties['image'];
+            if (!empty($visibleFileTitles)) {
+                $constraint = $this->getRequestSectionStructureHasRecordConstraint()
+                    ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
+                    ->setTable('sys_file_reference')->setField('title');
+                call_user_func_array([$constraint, 'setValues'], $visibleFileTitles);
+                $this->assertThat($responseSections, $constraint);
+            }
+            $constraint = $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
+                ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
+                ->setTable('sys_file_reference')->setField('title');
+            call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleFileTitles($visibleFileTitles));
+            $this->assertThat($responseSections, $constraint);
+        }
     }
 
     public function contentOnNonTranslatedPageDataProvider()
@@ -320,83 +659,276 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
             [
                 'typoScript' => 'config.sys_language_overlay = 0
                                 config.sys_language_mode =',
-                'visibleRecordHeaders' => ['Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => 'Regular Element #1',
+                        'image' => ['T3BOARD'],
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => 'Regular Element #3',
+                        'image' => [],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 0
                                 config.sys_language_mode = content_fallback',
-                'visibleRecordHeaders' => ['Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => 'Regular Element #1',
+                        'image' => ['T3BOARD'],
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => 'Regular Element #3',
+                        'image' => [],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 0
                                 config.sys_language_mode = content_fallback;1,0',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', 'Regular Element #2', '[Translate to Dansk:] Regular Element #3', '[DK] UnHidden Element #4', '[DK] Without default language'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 0
                                 config.sys_language_mode = strict',
-                'visibleRecordHeaders' => [],
+                'visibleRecords' => [],
                 'status' => 404,
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 0
                                 config.sys_language_mode = ignore',
-                'visibleRecordHeaders' => ['[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1', 'Regular Element #2', 'Regular Element #3', '[DE] Without default language'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => 'Regular Element #3',
+                        'image' => []
+                    ],
+                    304 => [
+                        'header' => '[DE] Without default language',
+                        'image' => [],
+                    ],
+                ],
             ],
             5 => [
                 'typoScript' => 'config.sys_language_overlay = 1
                                 config.sys_language_mode =',
-                'visibleRecordHeaders' => ['Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => 'Regular Element #1',
+                        'image' => ['T3BOARD'],
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => 'Regular Element #3',
+                        'image' => [],
+                    ],
+                ],
             ],
             //falling back to default language
             [
                 'typoScript' => 'config.sys_language_overlay = 1
                                 config.sys_language_mode = content_fallback',
-                'visibleRecordHeaders' => ['Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => 'Regular Element #1',
+                        'image' => ['T3BOARD'],
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => 'Regular Element #3',
+                        'image' => [],
+                    ],
+                ],
             ],
             //Dutch elements are shown because of the content fallback 1,0 - first Dutch, then default language
             //note that '[DK] Without default language' is NOT shown - due to overlays (fetch default language and overlay it with translations)
             [
                 'typoScript' => 'config.sys_language_overlay = 1
                                 config.sys_language_mode = content_fallback;1,0',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', 'Regular Element #2', '[Translate to Dansk:] Regular Element #3', '[DK] Without default language', '[DK] UnHidden Element #4'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 1
                                 config.sys_language_mode = strict',
-                'visibleRecordHeaders' => [],
+                'visibleRecords' => [],
                 'status' => 404
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = 1
                                 config.sys_language_mode = ignore',
-                'visibleRecordHeaders' => ['[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1', 'Regular Element #2', 'Regular Element #3', '[DE] Without default language'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => 'Regular Element #3',
+                        'image' => []
+                    ],
+                    304 => [
+                        'header' => '[DE] Without default language',
+                        'image' => [],
+                    ],
+                ],
             ],
             10 => [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
                                 config.sys_language_mode =',
-                'visibleRecordHeaders' => ['Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => 'Regular Element #1',
+                        'image' => ['T3BOARD'],
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => 'Regular Element #3',
+                        'image' => [],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
                                 config.sys_language_mode = content_fallback',
-                'visibleRecordHeaders' => ['Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => 'Regular Element #1',
+                        'image' => ['T3BOARD'],
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => 'Regular Element #3',
+                        'image' => [],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
                                 config.sys_language_mode = content_fallback;1,0',
-                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #3', 'Regular Element #2', '[DK] Without default language', '[DK] UnHidden Element #4'],
+//                'visibleRecordHeaders' => ['[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #3', 'Regular Element #2', '[DK] Without default language', '[DK] UnHidden Element #4'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => '[Translate to Dansk:] Regular Element #3',
+                        'image' => []
+                    ],
+                    303 => [
+                        'header' => '[DK] Without default language',
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
+                    ],
+                    307 => [
+                        'header' => '[DK] UnHidden Element #4',
+                        'image' => [],
+                    ],
+                ],
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
                                 config.sys_language_mode = strict',
-                'visibleRecordHeaders' => [],
+                'visibleRecords' => [],
                 'status' => 404,
             ],
             [
                 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
                                 config.sys_language_mode = ignore',
-                'visibleRecordHeaders' => ['[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1', 'Regular Element #2', 'Regular Element #3', '[DE] Without default language'],
+                'visibleRecords' => [
+                    297 => [
+                        'header' => '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
+                        'image' => ['T3BOARD'],
+                    ],
+                    298 => [
+                        'header' => 'Regular Element #2',
+                        'image' => ['Kasper'],
+                    ],
+                    299 => [
+                        'header' => 'Regular Element #3',
+                        'image' => []
+                    ],
+                    304 => [
+                        'header' => '[DE] Without default language',
+                        'image' => [],
+                    ],
+                ],
             ],
         ];
     }
@@ -408,27 +940,48 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
      * @dataProvider contentOnNonTranslatedPageDataProvider
      *
      * @param string $typoScript
-     * @param array $visibleHeaders
+     * @param array $visibleRecords
      * @param string $status 'success' or 404
      */
-    public function contentOnNonTranslatedPageGerman($typoScript, array $visibleHeaders, $status='success')
+    public function contentOnNonTranslatedPageGerman($typoScript, array $visibleRecords, $status='success')
     {
         $this->addTypoScriptToTemplateRecord(1, $typoScript);
+        $visibleHeaders = array_map(function ($element) {
+            return $element['header'];
+        }, $visibleRecords);
 
         $frontendResponse = $this->getFrontendResponse(self::VALUE_PageId, 2);
         if ($status === 'success') {
             $responseSections = $frontendResponse->getResponseSections('Extbase:list()');
-            $constraint = $this->getRequestSectionHasRecordConstraint()
+            $constraint =
+                $this->getRequestSectionHasRecordConstraint()
                 ->setTable(self::TABLE_Content)
                 ->setField('header');
-            call_user_func_array([$constraint, 'setValues'], $visibleHeaders);
-            $this->assertThat($responseSections, $constraint);
+                call_user_func_array([$constraint, 'setValues'],$visibleHeaders);
 
-            $constraint = $this->getRequestSectionDoesNotHaveRecordConstraint()
+            $this->assertThat(
+                $responseSections,$constraint);
+               $constraint = $this->getRequestSectionDoesNotHaveRecordConstraint()
                 ->setTable(self::TABLE_Content)
                 ->setField('header');
-            call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleHeaders($visibleHeaders));
+                call_user_func_array([$constraint, 'setValues'],$this->getNonVisibleHeaders($visibleHeaders));
             $this->assertThat($responseSections, $constraint);
+
+            foreach ($visibleRecords as $ttContentUid => $properties) {
+                $visibleFileTitles = $properties['image'];
+                if (!empty($visibleFileTitles)) {
+                    $constraint = $this->getRequestSectionStructureHasRecordConstraint()
+                        ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
+                        ->setTable('sys_file_reference')->setField('title');
+                    call_user_func_array([$constraint, 'setValues'], $visibleFileTitles);
+                    $this->assertThat($responseSections, $constraint);
+                }
+                $constraint = $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
+                    ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
+                    ->setTable('sys_file_reference')->setField('title');
+                call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleFileTitles($visibleFileTitles));
+                $this->assertThat($responseSections, $constraint);
+            }
         }
         //some configuration combinations results in 404, in that case status will be set to 404
         $this->assertEquals($status, $frontendResponse->getStatus());
@@ -543,16 +1096,18 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
         $this->assertEquals('success', $frontendResponse->getStatus());
         $responseSections = $frontendResponse->getResponseSections('Extbase:list()');
 
-        $constraint = $this->getRequestSectionHasRecordConstraint()
+        $constraint =
+            $this->getRequestSectionHasRecordConstraint()
             ->setTable(self::TABLE_Content)
             ->setField('header');
-        call_user_func_array([$constraint, 'setValues'], $visibleHeaders);
-        $this->assertThat($responseSections, $constraint);
+            call_user_func_array([$constraint, 'setValues'],$visibleHeaders);
 
-        $constraint = $this->getRequestSectionDoesNotHaveRecordConstraint()
+        $this->assertThat(
+            $responseSections,$constraint);
+           $constraint = $this->getRequestSectionDoesNotHaveRecordConstraint()
             ->setTable(self::TABLE_Content)
             ->setField('header');
-        call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleHeaders($visibleHeaders));
+            call_user_func_array([$constraint, 'setValues'],$this->getNonVisibleHeaders($visibleHeaders));
         $this->assertThat($responseSections, $constraint);
     }
 
@@ -583,6 +1138,25 @@ class TranslatedContentTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandlin
     }
 
     /**
+     * Helper function to ease asserting that rest of the data set is not visible
+     *
+     * @param array $visibleTitles
+     * @return array
+     */
+    protected function getNonVisibleFileTitles(array $visibleTitles)
+    {
+        $allElements = [
+            'T3BOARD',
+            'Kasper',
+            '[Kasper] Image translated to Dansk',
+            '[T3BOARD] Image added in Dansk (without parent)',
+            '[T3BOARD] Image added to DK element without default language',
+            '[T3BOARD] image translated to DE from DK',
+        ];
+        return array_diff($allElements, $visibleTitles);
+    }
+
+    /**
      * Adds TypoScript setup snippet to the existing template record
      *
      * @param int $pageId
index 8249a17..7139e8d 100644 (file)
@@ -4,20 +4,20 @@ sys_language,,,,,,,,,,,,,,,,,,,,,,,
 ,2,0,0,Deutsch,de,,,,,,,,,,,,,,,,,,
 ,3,0,0,Polski,pl,,,,,,,,,,,,,,,,,,
 tt_content,,,,,,,,,,,,,,,,,,,,,,,
-,uid,pid,sorting,deleted,hidden,sys_language_uid,l18n_parent,t3_origuid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,image,header,,,,,,,,
-,297,89,256,0,0,0,0,0,0,0,0,0,0,1,Regular Element #1,,,,,,,,
-,298,89,512,0,0,0,0,0,0,0,0,0,0,1,Regular Element #2,,,,,,,,
-,299,89,768,0,0,0,0,0,0,0,0,0,0,0,Regular Element #3,,,,,,,,
-,300,89,1024,0,0,1,299,299,0,0,0,0,0,2,[Translate to Dansk:] Regular Element #3,,,,,,,,
-,301,89,384,0,0,1,297,297,0,0,0,0,0,0,[Translate to Dansk:] Regular Element #1,,,,,,,,
-,302,89,448,0,0,2,297,301,0,0,0,0,0,1,[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1,,,,,,,,
-,303,89,1250,0,0,1,0,0,0,0,0,0,0,1,[DK] Without default language,,,,,,,,
-,304,89,1250,0,0,2,0,0,0,0,0,0,0,0,[DE] Without default language,,,,,,,,
-,305,89,512,0,0,3,297,297,0,0,0,0,0,0,[Translate to Polski:] Regular Element #1,,,,,,,,
-,306,89,1024,0,0,3,0,0,0,0,0,0,0,0,[PL] Without default language,,,,,,,,
-,307,89,128,0,1,0,0,0,0,0,0,0,0,0,Hidden Element #4,,,,,,,,
-,308,89,128,0,0,1,307,307,0,0,0,0,0,0,[DK] UnHidden Element #4,,,,,,,,
-,309,89,512,0,1,3,298,298,0,0,0,0,0,0,[PL] Hidden Regular Element #2,,,,,,,,
+,uid,pid,header,image,sorting,deleted,hidden,sys_language_uid,l18n_parent,t3_origuid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,,,,,,,,
+,297,89,Regular Element #1,1,256,0,0,0,0,0,0,0,0,0,0,,,,,,,,
+,298,89,Regular Element #2,1,512,0,0,0,0,0,0,0,0,0,0,,,,,,,,
+,299,89,Regular Element #3,0,768,0,0,0,0,0,0,0,0,0,0,,,,,,,,
+,300,89,[Translate to Dansk:] Regular Element #3,2,1024,0,0,1,299,299,0,0,0,0,0,,,,,,,,
+,301,89,[Translate to Dansk:] Regular Element #1,0,384,0,0,1,297,297,0,0,0,0,0,,,,,,,,
+,302,89,[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1,1,448,0,0,2,297,301,0,0,0,0,0,,,,,,,,
+,303,89,[DK] Without default language,1,1250,0,0,1,0,0,0,0,0,0,0,,,,,,,,
+,304,89,[DE] Without default language,0,1250,0,0,2,0,0,0,0,0,0,0,,,,,,,,
+,305,89,[Translate to Polski:] Regular Element #1,0,512,0,0,3,297,297,0,0,0,0,0,,,,,,,,
+,306,89,[PL] Without default language,0,1024,0,0,3,0,0,0,0,0,0,0,,,,,,,,
+,307,89,Hidden Element #4,0,128,0,1,0,0,0,0,0,0,0,0,,,,,,,,
+,308,89,[DK] UnHidden Element #4,0,128,0,0,1,307,307,0,0,0,0,0,,,,,,,,
+,309,89,[PL] Hidden Regular Element #2,0,512,0,1,3,298,298,0,0,0,0,0,,,,,,,,
 ,,,,,,,,,,,,,,,,,,,,,,,
 ,,,,,,,,,,,,,,,,,,,,,,,
 ,,,,,,,,,,,,,,,,,,,,,,,
@@ -32,10 +32,10 @@ sys_file_metadata,,,,,,,,,,,,,,,,,,,,,,,
 ,1,0,0,0,0,0,0,0,0,0,1,Image Kasper,401,600,,,0,,,,,,
 ,21,0,0,0,0,0,0,0,0,0,21,Image T3BOARD,1024,683,,,0,,,,,,
 sys_file_reference,,,,,,,,,,,,,,,,,,,,,,,
-,uid,pid,sorting,deleted,sys_language_uid,l10n_parent,t3_origuid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,uid_local,uid_foreign,tablenames,fieldname,sorting_foreign,table_local,title,description,alternative,link,l10n_diffsource
-,126,89,128,0,0,0,0,0,0,0,0,0,1,297,tt_content,image,2,sys_file,T3BOARD,,,,
-,127,89,64,0,0,0,0,0,0,0,0,0,21,298,tt_content,image,1,sys_file,Kasper,,,,
-,128,89,32,0,1,127,127,0,0,0,0,0,21,300,tt_content,image,1,sys_file,[Kasper] Image translated to Dansk,,,,
-,129,89,16,0,1,0,0,0,0,0,0,0,1,300,tt_content,image,2,sys_file,[T3BOARD] Image added in Dansk (without parent),,,,
-,130,89,8,0,1,0,0,0,0,0,0,0,1,303,tt_content,image,1,sys_file,[T3BOARD] Image added to DK elemet without default language,,,,
-,131,89,8,0,2,0,0,0,0,0,0,0,1,302,tt_content,image,1,sys_file,[T3BOARD] image translated to DE from DK,,,,
+,uid,pid,title,uid_local,uid_foreign,sys_language_uid,l10n_parent,t3_origuid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,sorting,deleted,tablenames,fieldname,sorting_foreign,table_local,description,alternative,link,l10n_diffsource
+,126,89,T3BOARD,1,297,0,0,0,0,0,0,0,0,128,0,tt_content,image,2,sys_file,,,,
+,127,89,Kasper,21,298,0,0,0,0,0,0,0,0,64,0,tt_content,image,1,sys_file,,,,
+,128,89,[Kasper] Image translated to Dansk,21,300,1,127,127,0,0,0,0,0,32,0,tt_content,image,1,sys_file,,,,
+,129,89,[T3BOARD] Image added in Dansk (without parent),1,300,1,0,0,0,0,0,0,0,16,0,tt_content,image,2,sys_file,,,,
+,130,89,[T3BOARD] Image added to DK element without default language,1,303,1,0,0,0,0,0,0,0,8,0,tt_content,image,1,sys_file,,,,
+,131,89,[T3BOARD] image translated to DE from DK,1,302,2,0,0,0,0,0,0,0,8,0,tt_content,image,1,sys_file,,,,
index ce17110..7803961 100644 (file)
@@ -294,7 +294,7 @@ class LocalizedContentRenderingTest extends \TYPO3\CMS\Core\Tests\Functional\Dat
                     ],
                     303 => [
                         'header' => '[DK] Without default language',
-                        'image' => ['[T3BOARD] Image added to DK elemet without default language']
+                        'image' => ['[T3BOARD] Image added to DK element without default language']
                     ],
                     308 => [
                         'header' => '[DK] UnHidden Element #4',
@@ -318,7 +318,7 @@ class LocalizedContentRenderingTest extends \TYPO3\CMS\Core\Tests\Functional\Dat
                     ],
                     303 => [
                         'header' => '[DK] Without default language',
-                        'image' => ['[T3BOARD] Image added to DK elemet without default language']
+                        'image' => ['[T3BOARD] Image added to DK element without default language']
                     ],
                     308 => [
                         'header' => '[DK] UnHidden Element #4',
@@ -342,7 +342,7 @@ class LocalizedContentRenderingTest extends \TYPO3\CMS\Core\Tests\Functional\Dat
                     ],
                     303 => [
                         'header' => '[DK] Without default language',
-                        'image' => ['[T3BOARD] Image added to DK elemet without default language']
+                        'image' => ['[T3BOARD] Image added to DK element without default language']
                     ],
                     308 => [
                         'header' => '[DK] UnHidden Element #4',
@@ -366,7 +366,7 @@ class LocalizedContentRenderingTest extends \TYPO3\CMS\Core\Tests\Functional\Dat
                     ],
                     303 => [
                         'header' => '[DK] Without default language',
-                        'image' => ['[T3BOARD] Image added to DK elemet without default language']
+                        'image' => ['[T3BOARD] Image added to DK element without default language']
                     ],
                     308 => [
                         'header' => '[DK] UnHidden Element #4',
@@ -390,7 +390,7 @@ class LocalizedContentRenderingTest extends \TYPO3\CMS\Core\Tests\Functional\Dat
                     ],
                     303 => [
                         'header' => '[DK] Without default language',
-                        'image' => ['[T3BOARD] Image added to DK elemet without default language']
+                        'image' => ['[T3BOARD] Image added to DK element without default language']
                     ],
                     308 => [
                         'header' => '[DK] UnHidden Element #4',
@@ -712,7 +712,7 @@ class LocalizedContentRenderingTest extends \TYPO3\CMS\Core\Tests\Functional\Dat
                     ],
                     303 => [
                         'header' => '[DK] Without default language',
-                        'image' => ['[T3BOARD] Image added to DK elemet without default language'],
+                        'image' => ['[T3BOARD] Image added to DK element without default language'],
                     ],
                     308 => [
                         'header' => '[DK] UnHidden Element #4',
@@ -1215,11 +1215,11 @@ class LocalizedContentRenderingTest extends \TYPO3\CMS\Core\Tests\Functional\Dat
     protected function getNonVisibleFileTitles(array $visibleTitles)
     {
         $allElements = [
-            'T3BOARDD',
+            'T3BOARD',
             'Kasper',
             '[Kasper] Image translated to Dansk',
             '[T3BOARD] Image added in Dansk (without parent)',
-            '[T3BOARD] Image added to DK elemet without default language',
+            '[T3BOARD] Image added to DK element without default language',
             '[T3BOARD] image translated to DE from DK',
         ];
         return array_diff($allElements, $visibleTitles);