TYPO3 CMS  TYPO3_7-6
ExportTest.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 
18 
23 {
25  'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/fileadmin/user_upload' => 'fileadmin/user_upload'
26  ];
27 
28  protected function setUp()
29  {
30  parent::setUp();
31 
32  $this->importDataSet(__DIR__ . '/../../Fixtures/Database/pages.xml');
33  $this->importDataSet(__DIR__ . '/../../Fixtures/Database/tt_content-with-image.xml');
34  $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_language.xml');
35  $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file_metadata.xml');
36  $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file_reference.xml');
37  $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file_storage.xml');
38  }
39 
44  {
45  $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file.xml');
46 
48 
49  $out = $this->export->compileMemoryToFileContent('xml');
50 
51  $errors = $this->export->printErrorLog();
52  $this->assertSame('', $errors);
53 
54  $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../../Fixtures/ImportExportXml/pages-and-ttcontent-with-image.xml', $out);
55  }
56 
61  {
62  $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file_corrupt.xml');
63 
65 
66  $out = $this->export->compileMemoryToFileContent('xml');
67 
68  $expectedErrors = [
69  'File size of 1:/user_upload/typo3_image2.jpg is not up-to-date in index! File added with current size.',
70  'File sha1 hash of 1:/user_upload/typo3_image2.jpg is not up-to-date in index! File added on current sha1.'
71  ];
72  $errors = $this->export->errorLog;
73  $this->assertSame($expectedErrors, $errors);
74 
75  $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../../Fixtures/ImportExportXml/pages-and-ttcontent-with-image.xml', $out);
76  }
77 
82  {
83  $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file.xml');
84 
85  $this->export->setSaveFilesOutsideExportFile(true);
86 
88 
89  $out = $this->export->compileMemoryToFileContent('xml');
90 
91  $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../../Fixtures/ImportExportXml/pages-and-ttcontent-with-image-but-not-included.xml', $out);
92 
93  $temporaryFilesDirectory = $this->export->getTemporaryFilesPathForExport();
94  $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', $temporaryFilesDirectory . 'da9acdf1e105784a57bbffec9520969578287797');
95  }
96 
98  {
99  $this->export->setRecordTypesIncludeFields(
100  [
101  'pages' => [
102  'title',
103  'deleted',
104  'doktype',
105  'hidden',
106  'perms_everybody'
107  ],
108  'tt_content' => [
109  'CType',
110  'header',
111  'header_link',
112  'deleted',
113  'hidden',
114  'image',
115  't3ver_oid'
116  ],
117  'sys_language' => [
118  'uid',
119  'pid',
120  'hidden',
121  'title',
122  'flag'
123  ],
124  'sys_file_reference' => [
125  'uid_local',
126  'uid_foreign',
127  'tablenames',
128  'fieldname',
129  'sorting_foreign',
130  'table_local',
131  'title',
132  'description',
133  'alternative',
134  'link',
135  ],
136  'sys_file' => [
137  'storage',
138  'type',
139  'metadata',
140  'identifier',
141  'identifier_hash',
142  'folder_hash',
143  'mime_type',
144  'name',
145  'sha1',
146  'size',
147  'creation_date',
148  'modification_date',
149  ],
150  'sys_file_storage' => [
151  'name',
152  'description',
153  'driver',
154  'configuration',
155  'is_default',
156  'is_browsable',
157  'is_public',
158  'is_writable',
159  'is_online'
160  ],
161  'sys_file_metadata' => [
162  'title',
163  'width',
164  'height',
165  'description',
166  'alternative',
167  'file',
168  'sys_language_uid',
169  'l10n_parent'
170  ]
171  ]
172  );
173 
174  $this->export->relOnlyTables = [
175  'sys_file',
176  'sys_file_metadata',
177  'sys_file_storage',
178  'sys_language'
179  ];
180 
181  $this->export->export_addRecord('pages', BackendUtility::getRecord('pages', 1));
182  $this->export->export_addRecord('pages', BackendUtility::getRecord('pages', 2));
183  $this->export->export_addRecord('tt_content', BackendUtility::getRecord('tt_content', 1));
184  $this->export->export_addRecord('sys_language', BackendUtility::getRecord('sys_language', 1));
185  $this->export->export_addRecord('sys_file_reference', BackendUtility::getRecord('sys_file_reference', 1));
186 
187  $this->setPageTree(1, 1);
188 
189  // After adding ALL records we set relations:
190  for ($a = 0; $a < 10; $a++) {
191  $addR = $this->export->export_addDBRelations($a);
192  if (empty($addR)) {
193  break;
194  }
195  }
196 
197  $this->export->export_addFilesFromRelations();
198  $this->export->export_addFilesFromSysFilesRecords();
199  }
200 }
static getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)