TYPO3 CMS  TYPO3_8-7
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 {
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/' . $this->databasePlatform . '/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 size of 1:/user_upload/typo3_image2.jpg is not up-to-date in index! File added with current size.',
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  $this->assertSame($expectedErrors, $errors);
89 
90  $this->assertXmlStringEqualsXmlFile(
91  __DIR__ . '/../Fixtures/XmlExports/' . $this->databasePlatform . '/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  $this->assertXmlStringEqualsXmlFile(
113  __DIR__ . '/../Fixtures/XmlExports/' . $this->databasePlatform . '/pages-and-ttcontent-with-image-but-not-included.xml',
114  $out
115  );
116 
117  $temporaryFilesDirectory = $subject->getTemporaryFilesPathForExport();
118  $this->assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', $temporaryFilesDirectory . 'da9acdf1e105784a57bbffec9520969578287797');
119  }
120 
127  {
128  $subject->setRecordTypesIncludeFields(
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  $subject->export_addRecord('pages', BackendUtility::getRecord('pages', 1));
211  $subject->export_addRecord('pages', BackendUtility::getRecord('pages', 2));
212  $subject->export_addRecord('tt_content', BackendUtility::getRecord('tt_content', 1));
213  $subject->export_addRecord('sys_language', BackendUtility::getRecord('sys_language', 1));
214  $subject->export_addRecord('sys_file_reference', 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 
226  $subject->export_addFilesFromRelations();
228  }
229 }
export_addDBRelations($relationLevel=0)
Definition: Export.php:438
export_addFilesFromSysFilesRecords()
Definition: Export.php:644
static makeInstance($className,... $constructorArguments)
setRecordTypesIncludeFields(array $recordTypesIncludeFields)
Definition: Export.php:271
export_addRecord($table, $row, $relationLevel=0)
Definition: Export.php:300
static getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)