‪TYPO3CMS  ‪main
PagesAndTtContentWithRelationsAndSoftrefsTest.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 
20 use PHPUnit\Framework\Attributes\Test;
23 
25 {
26  protected array ‪$pathsToLinkInTestInstance = [
27  'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/fileadmin/user_upload' => 'fileadmin/user_upload',
28  'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/fileadmin/form_definitions' => 'fileadmin/form_definitions',
29  ];
30 
31  protected array ‪$recordTypesIncludeFields =
32  [
33  'pages' => [
34  'title',
35  'deleted',
36  'doktype',
37  'hidden',
38  'perms_everybody',
39  ],
40  'tt_content' => [
41  'CType',
42  'header',
43  'header_link',
44  'list_type',
45  'pi_flexform',
46  'deleted',
47  'hidden',
48  't3ver_oid',
49  ],
50  'sys_file' => [
51  'storage',
52  'type',
53  'metadata',
54  'identifier',
55  'identifier_hash',
56  'folder_hash',
57  'mime_type',
58  'name',
59  'sha1',
60  'size',
61  'creation_date',
62  'modification_date',
63  ],
64  ]
65  ;
66 
67  #[Test]
69  {
70  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/pages.csv');
71  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/tt_content-with-flexform-relation.csv');
72 
73  ‪$GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds']['default'] = '
74 <T3DataStructure>
75  <ROOT>
76  <type>array</type>
77  <el>
78  <flexFormRelation>
79  <label>FlexForm relation</label>
80  <config>
81  <type>group</type>
82  <allowed>pages</allowed>
83  <size>1</size>
84  <maxitems>1</maxitems>
85  <minitems>0</minitems>
86  </config>
87  </flexFormRelation>
88  </el>
89  </ROOT>
90 </T3DataStructure>';
91 
92  $subject = $this->getAccessibleMock(Export::class, ['setMetaData']);
93  $subject->setPid(1);
94  $subject->setLevels(1);
95  $subject->setTables(['tt_content']);
96  $subject->setRelOnlyTables(['pages']);
97  $subject->setRecordTypesIncludeFields($this->recordTypesIncludeFields);
98  $subject->process();
99 
100  $out = $subject->render();
101 
102  // @todo Use self::assertXmlStringEqualsXmlFile() instead when sqlite issue is sorted out
104  __DIR__ . '/../Fixtures/XmlExports/pages-and-ttcontent-with-flexform-relation.xml',
105  $out
106  );
107  }
108 
109  #[Test]
111  {
112  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/pages.csv');
113  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/tt_content-with-softrefs.csv');
114  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file.csv');
115 
116  ‪$GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds']['default'] = '
117 <T3DataStructure>
118  <ROOT>
119  <type>array</type>
120  <el>
121  <softrefLink>
122  <label>Soft reference link</label>
123  <config>
124  <type>link</type>
125  <allowedTypes>page,file,url,record,telephone</allowedTypes>
126  <appearance>
127  <browserTitle>Link</browserTitle>
128  </appearance>
129  </config>
130  </softrefLink>
131  </el>
132  </ROOT>
133 </T3DataStructure>';
134 
135  $subject = $this->getAccessibleMock(Export::class, ['setMetaData']);
136  $subject->setPid(1);
137  $subject->setLevels(1);
138  $subject->setTables(['_ALL']);
139  $subject->setRelOnlyTables(['sys_file']);
140  $subject->setRecordTypesIncludeFields($this->recordTypesIncludeFields);
141  $subject->process();
142 
143  $out = $subject->render();
144 
145  // @todo Use self::assertXmlStringEqualsXmlFile() instead when sqlite issue is sorted out
147  __DIR__ . '/../Fixtures/XmlExports/pages-and-ttcontent-with-softrefs.xml',
148  $out
149  );
150  }
151 
152  #[Test]
154  {
155  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/pages.csv');
156  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/tt_content-with-flexform-softrefs.csv');
157  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/form_sys_file.csv');
158 
159  ‪$GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds']['default'] = '
160 <T3DataStructure>
161  <sheets>
162  <sDEF>
163  <ROOT>
164  <sheetTitle>LLL:EXT:form/Resources/Private/Language/Database.xlf:tt_content.pi_flexform.formframework.sheet_general</sheetTitle>
165  <type>array</type>
166  <el>
167  <settings.persistenceIdentifier>
168  <label>LLL:EXT:form/Resources/Private/Language/Database.xlf:tt_content.pi_flexform.formframework.persistenceIdentifier</label>
169  <onChange>reload</onChange>
170  <config>
171  <type>select</type>
172  <renderType>selectSingle</renderType>
173  <items>
174  <numIndex index="0" type="array">
175  <numIndex index="0">LLL:EXT:form/Resources/Private/Language/Database.xlf:tt_content.pi_flexform.formframework.selectPersistenceIdentifier</numIndex>
176  <numIndex index="1"></numIndex>
177  </numIndex>
178  </items>
179  <softref>formPersistenceIdentifier</softref>
180  </config>
181  </settings.persistenceIdentifier>
182  </el>
183  </ROOT>
184  </sDEF>
185  </sheets>
186 </T3DataStructure>';
187 
188  $subject = $this->getAccessibleMock(Export::class, ['setMetaData']);
189  $subject->setPid(1);
190  $subject->setLevels(1);
191  $subject->setTables(['_ALL']);
192  $subject->setRelOnlyTables(['sys_file']);
193  $subject->setRecordTypesIncludeFields($this->recordTypesIncludeFields);
194  $subject->process();
195 
196  $out = $subject->render();
197 
198  // @todo Use self::assertXmlStringEqualsXmlFile() instead when sqlite issue is sorted out
200  __DIR__ . '/../Fixtures/XmlExports/pages-and-ttcontent-with-flexform-softrefs.xml',
201  $out
202  );
203  }
204 }
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithRelationsAndSoftrefsTest\exportPagesAndRelatedTtContentWithSoftrefs
‪exportPagesAndRelatedTtContentWithSoftrefs()
Definition: PagesAndTtContentWithRelationsAndSoftrefsTest.php:110
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\assertXmlStringEqualsXmlFileWithIgnoredSqliteTypeInteger
‪assertXmlStringEqualsXmlFileWithIgnoredSqliteTypeInteger(string $expectedFile, string $actualXml)
Definition: AbstractImportExportTestCase.php:92
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithRelationsAndSoftrefsTest\exportPagesAndRelatedTtContentWithFlexFormRelation
‪exportPagesAndRelatedTtContentWithFlexFormRelation()
Definition: PagesAndTtContentWithRelationsAndSoftrefsTest.php:68
‪TYPO3\CMS\Impexp\Tests\Functional\Export
Definition: IrreRecordsTest.php:18
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase
Definition: AbstractImportExportTestCase.php:33
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Impexp\Export
Definition: Export.php:52
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithRelationsAndSoftrefsTest\$recordTypesIncludeFields
‪array $recordTypesIncludeFields
Definition: PagesAndTtContentWithRelationsAndSoftrefsTest.php:31
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithRelationsAndSoftrefsTest\exportPagesAndRelatedTtContentWithFlexFormSoftrefs
‪exportPagesAndRelatedTtContentWithFlexFormSoftrefs()
Definition: PagesAndTtContentWithRelationsAndSoftrefsTest.php:153
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithRelationsAndSoftrefsTest
Definition: PagesAndTtContentWithRelationsAndSoftrefsTest.php:25
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithRelationsAndSoftrefsTest\$pathsToLinkInTestInstance
‪array $pathsToLinkInTestInstance
Definition: PagesAndTtContentWithRelationsAndSoftrefsTest.php:26