‪TYPO3CMS  10.4
PagesAndTtContentWithImagesTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 
27 {
31  protected ‪$pathsToLinkInTestInstance = [
32  'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/fileadmin/user_upload' => 'fileadmin/user_upload'
33  ];
34 
35  protected function ‪setUp(): void
36  {
37  parent::setUp();
38 
39  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/pages.xml');
40  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/tt_content-with-image.xml');
41  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_language.xml');
42  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_metadata.xml');
43  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_reference.xml');
44  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_storage.xml');
45  }
46 
51  {
52  $subject = GeneralUtility::makeInstance(Export::class);
53  $subject->init();
54 
55  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file.xml');
56 
58 
59  $out = $subject->compileMemoryToFileContent('xml');
60 
61  ‪$errors = $subject->printErrorLog();
62  self::assertSame('', ‪$errors);
63 
64  self::assertXmlStringEqualsXmlFile(
65  __DIR__ . '/../Fixtures/XmlExports/pages-and-ttcontent-with-image.xml',
66  $out
67  );
68  }
69 
74  {
75  $subject = GeneralUtility::makeInstance(Export::class);
76  $subject->init();
77 
78  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_corrupt.xml');
79 
81 
82  $out = $subject->compileMemoryToFileContent('xml');
83 
84  $expectedErrors = [
85  'File sha1 hash of 1:/user_upload/typo3_image2.jpg is not up-to-date in index! File added on current sha1.'
86  ];
87  ‪$errors = $subject->errorLog;
88  self::assertSame($expectedErrors, ‪$errors);
89 
90  self::assertXmlStringEqualsXmlFile(
91  __DIR__ . '/../Fixtures/XmlExports/pages-and-ttcontent-with-corrupt-image.xml',
92  $out
93  );
94  }
95 
100  {
101  $subject = GeneralUtility::makeInstance(Export::class);
102  $subject->init();
103 
104  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file.xml');
105 
106  $subject->setSaveFilesOutsideExportFile(true);
107 
109 
110  $out = $subject->compileMemoryToFileContent('xml');
111 
112  self::assertXmlStringEqualsXmlFile(
113  __DIR__ . '/../Fixtures/XmlExports/pages-and-ttcontent-with-image-but-not-included.xml',
114  $out
115  );
116 
117  $temporaryFilesDirectory = $subject->getTemporaryFilesPathForExport();
118  self::assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', $temporaryFilesDirectory . 'da9acdf1e105784a57bbffec9520969578287797');
119  }
120 
127  {
129  [
130  'pages' => [
131  'title',
132  'deleted',
133  'doktype',
134  'hidden',
135  'perms_everybody'
136  ],
137  'tt_content' => [
138  'CType',
139  'header',
140  'header_link',
141  'deleted',
142  'hidden',
143  'image',
144  't3ver_oid'
145  ],
146  'sys_language' => [
147  'uid',
148  'pid',
149  'hidden',
150  'title',
151  'flag'
152  ],
153  'sys_file_reference' => [
154  'uid_local',
155  'uid_foreign',
156  'tablenames',
157  'fieldname',
158  'sorting_foreign',
159  'table_local',
160  'title',
161  'description',
162  'alternative',
163  'link',
164  ],
165  'sys_file' => [
166  'storage',
167  'type',
168  'metadata',
169  'identifier',
170  'identifier_hash',
171  'folder_hash',
172  'mime_type',
173  'name',
174  'sha1',
175  'size',
176  'creation_date',
177  'modification_date',
178  ],
179  'sys_file_storage' => [
180  'name',
181  'description',
182  'driver',
183  'configuration',
184  'is_default',
185  'is_browsable',
186  'is_public',
187  'is_writable',
188  'is_online'
189  ],
190  'sys_file_metadata' => [
191  'title',
192  'width',
193  'height',
194  'description',
195  'alternative',
196  'file',
197  'sys_language_uid',
198  'l10n_parent'
199  ]
200  ]
201  );
202 
203  $subject->relOnlyTables = [
204  'sys_file',
205  'sys_file_metadata',
206  'sys_file_storage',
207  'sys_language'
208  ];
209 
210  // @todo: Do not rely on BackendUtility::getRecord() in the test case itself
211  $subject->‪export_addRecord('pages', $this->‪forceStringsOnRowValues(‪BackendUtility::getRecord('pages', 1)));
212  $subject->‪export_addRecord('pages', $this->‪forceStringsOnRowValues(‪BackendUtility::getRecord('pages', 2)));
213  $subject->‪export_addRecord('tt_content', $this->‪forceStringsOnRowValues(‪BackendUtility::getRecord('tt_content', 1)));
214  $subject->‪export_addRecord('sys_language', $this->‪forceStringsOnRowValues(‪BackendUtility::getRecord('sys_language', 1)));
215  $subject->‪export_addRecord('sys_file_reference', $this->‪forceStringsOnRowValues(‪BackendUtility::getRecord('sys_file_reference', 1)));
216 
217  $this->‪setPageTree($subject, 1, 1);
218 
219  // After adding ALL records we set relations:
220  for ($a = 0; $a < 10; $a++) {
221  $addR = $subject->‪export_addDBRelations($a);
222  if (empty($addR)) {
223  break;
224  }
225  }
226 
229  }
230 }
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest
Definition: PagesAndTtContentWithImagesTest.php:27
‪TYPO3\CMS\Impexp\Export\export_addFilesFromSysFilesRecords
‪export_addFilesFromSysFilesRecords()
Definition: Export.php:620
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\exportPagesAndRelatedTtContentWithImagesButNotIncluded
‪exportPagesAndRelatedTtContentWithImagesButNotIncluded()
Definition: PagesAndTtContentWithImagesTest.php:98
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\setPageTree
‪setPageTree(Export $export, $pidToStart, $depth=1)
Definition: AbstractImportExportTestCase.php:81
‪TYPO3\CMS\Impexp\Export\setRecordTypesIncludeFields
‪setRecordTypesIncludeFields(array $recordTypesIncludeFields)
Definition: Export.php:247
‪TYPO3\CMS\Impexp\Export\export_addDBRelations
‪array export_addDBRelations($relationLevel=0)
Definition: Export.php:407
‪TYPO3\CMS\Impexp\Export\export_addFilesFromRelations
‪export_addFilesFromRelations()
Definition: Export.php:531
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Impexp\Export\export_addRecord
‪export_addRecord($table, $row, $relationLevel=0)
Definition: Export.php:276
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\compileExportPagesAndRelatedTtContentWithImages
‪compileExportPagesAndRelatedTtContentWithImages(Export $subject)
Definition: PagesAndTtContentWithImagesTest.php:125
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecord
‪static array null getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
Definition: BackendUtility.php:95
‪$errors
‪$errors
Definition: annotationChecker.php:121
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\exportPagesAndRelatedTtContentWithImages
‪exportPagesAndRelatedTtContentWithImages()
Definition: PagesAndTtContentWithImagesTest.php:49
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\exportPagesAndRelatedTtContentWithImagesFromCorruptSysFileRecord
‪exportPagesAndRelatedTtContentWithImagesFromCorruptSysFileRecord()
Definition: PagesAndTtContentWithImagesTest.php:72
‪TYPO3\CMS\Impexp\Tests\Functional\Export
Definition: ExportControllerTest.php:18
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase
Definition: AbstractImportExportTestCase.php:31
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\forceStringsOnRowValues
‪array forceStringsOnRowValues(array $row)
Definition: AbstractImportExportTestCase.php:157
‪TYPO3\CMS\Impexp\Export
Definition: Export.php:64
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\$pathsToLinkInTestInstance
‪array $pathsToLinkInTestInstance
Definition: PagesAndTtContentWithImagesTest.php:30
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\setUp
‪setUp()
Definition: PagesAndTtContentWithImagesTest.php:34
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46