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