[CLEANUP] Remove obsolete require_once from test files
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / Tests / Functional / Export / PagesAndTtContentWithImages / ExportTest.php
1 <?php
2 namespace TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImages;
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
17 use TYPO3\CMS\Backend\Utility\BackendUtility;
18
19 /**
20 * Functional test for the ImportExport
21 */
22 class ExportTest extends \TYPO3\CMS\Impexp\Tests\Functional\Export\AbstractExportTestCase {
23
24 protected $pathsToLinkInTestInstance = array(
25 'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/fileadmin/user_upload' => 'fileadmin/user_upload'
26 );
27
28 protected function setUp() {
29 parent::setUp();
30
31 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/pages.xml');
32 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/tt_content-with-image.xml');
33 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_language.xml');
34 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file_metadata.xml');
35 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file_reference.xml');
36 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file_storage.xml');
37
38 }
39
40 /**
41 * @test
42 */
43 public function exportPagesAndRelatedTtContentWithImages() {
44
45 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file.xml');
46
47 $this->compileExportPagesAndRelatedTtContentWithImages();
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
57 /**
58 * @test
59 */
60 public function exportPagesAndRelatedTtContentWithImagesFromCorruptSysFileRecord() {
61
62 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file_corrupt.xml');
63
64 $this->compileExportPagesAndRelatedTtContentWithImages();
65
66 $out = $this->export->compileMemoryToFileContent('xml');
67
68 $expectedErrors = array(
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
78 /**
79 * @test
80 */
81 public function exportPagesAndRelatedTtContentWithImagesButNotIncluded() {
82
83 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file.xml');
84
85 $this->export->setSaveFilesOutsideExportFile(TRUE);
86
87 $this->compileExportPagesAndRelatedTtContentWithImages();
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 }
97
98 protected function compileExportPagesAndRelatedTtContentWithImages() {
99
100 $this->export->setRecordTypesIncludeFields(
101 array(
102 'pages' => array(
103 'title',
104 'deleted',
105 'doktype',
106 'hidden',
107 'perms_everybody'
108 ),
109 'tt_content' => array(
110 'CType',
111 'header',
112 'header_link',
113 'deleted',
114 'hidden',
115 'image',
116 't3ver_oid'
117 ),
118 'sys_language' => array(
119 'uid',
120 'pid',
121 'hidden',
122 'title',
123 'flag'
124 ),
125 'sys_file_reference' => array(
126 'uid_local',
127 'uid_foreign',
128 'tablenames',
129 'fieldname',
130 'sorting_foreign',
131 'table_local',
132 'title',
133 'description',
134 'alternative',
135 'link',
136 ),
137 'sys_file' => array(
138 'storage',
139 'type',
140 'metadata',
141 'identifier',
142 'identifier_hash',
143 'folder_hash',
144 'mime_type',
145 'name',
146 'sha1',
147 'size',
148 'creation_date',
149 'modification_date',
150 ),
151 'sys_file_storage' => array(
152 'name',
153 'description',
154 'driver',
155 'configuration',
156 'is_default',
157 'is_browsable',
158 'is_public',
159 'is_writable',
160 'is_online'
161 ),
162 'sys_file_metadata' => array(
163 'title',
164 'width',
165 'height',
166 'description',
167 'alternative',
168 'file',
169 'sys_language_uid',
170 'l10n_parent'
171 )
172 )
173 );
174
175 $this->export->relOnlyTables = array(
176 'sys_file',
177 'sys_file_metadata',
178 'sys_file_storage',
179 'sys_language'
180 );
181
182 $this->export->export_addRecord('pages', BackendUtility::getRecord('pages', 1));
183 $this->export->export_addRecord('pages', BackendUtility::getRecord('pages', 2));
184 $this->export->export_addRecord('tt_content', BackendUtility::getRecord('tt_content', 1));
185 $this->export->export_addRecord('sys_language', BackendUtility::getRecord('sys_language', 1));
186 $this->export->export_addRecord('sys_file_reference', BackendUtility::getRecord('sys_file_reference', 1));
187
188 $this->setPageTree(1, 1);
189
190 // After adding ALL records we set relations:
191 for ($a = 0; $a < 10; $a++) {
192 $addR = $this->export->export_addDBRelations($a);
193 if (empty($addR)) {
194 break;
195 }
196 }
197
198 $this->export->export_addFilesFromRelations();
199 $this->export->export_addFilesFromSysFilesRecords();
200 }
201
202 }