[TASK] Export binary data from sys_file records
[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 * Copyright notice
6 *
7 * (c) 2014 Marc Bastian Heinrichs <typo3@mbh-software.de>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 use TYPO3\CMS\Backend\Utility\BackendUtility;
28
29 require_once __DIR__ . '/../AbstractExportTestCase.php';
30
31 /**
32 * Functional test for the ImportExport
33 */
34 class ExportTest extends \TYPO3\CMS\Impexp\Tests\Functional\Export\AbstractExportTestCase {
35
36
37
38 protected $pathsToLinkInTestInstance = array(
39 'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/fileadmin/user_upload' => 'fileadmin/user_upload'
40 );
41
42 public function setUp() {
43 parent::setUp();
44
45 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/pages.xml');
46 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/tt_content-with-image.xml');
47 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_language.xml');
48 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file.xml');
49 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file_metadata.xml');
50 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file_reference.xml');
51 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file_storage.xml');
52
53 }
54
55 /**
56 * @test
57 */
58 public function exportPagesAndRelatedTtContentWithImages() {
59
60 $this->export->setRecordTypesIncludeFields(
61 array(
62 'pages' => array(
63 'title',
64 'deleted',
65 'doktype',
66 'hidden',
67 'perms_everybody'
68 ),
69 'tt_content' => array(
70 'CType',
71 'header',
72 'deleted',
73 'hidden',
74 'image',
75 't3ver_oid'
76 ),
77 'sys_language' => array(
78 'uid',
79 'pid',
80 'hidden',
81 'title',
82 'flag'
83 ),
84 'sys_file_reference' => array(
85 'uid_local',
86 'uid_foreign',
87 'tablenames',
88 'fieldname',
89 'sorting_foreign',
90 'table_local',
91 'title',
92 'description',
93 'alternative',
94 'link',
95 ),
96 'sys_file' => array(
97 'storage',
98 'type',
99 'metadata',
100 'identifier',
101 'identifier_hash',
102 'folder_hash',
103 'mime_type',
104 'name',
105 'sha1',
106 'size',
107 'creation_date',
108 'modification_date',
109 ),
110 'sys_file_storage' => array(
111 'name',
112 'description',
113 'driver',
114 'configuration',
115 'is_default',
116 'is_browsable',
117 'is_public',
118 'is_writable',
119 'is_online'
120 ),
121 'sys_file_metadata' => array(
122 'title',
123 'width',
124 'height',
125 'description',
126 'alternative',
127 'file',
128 'sys_language_uid',
129 'l10n_parent'
130 )
131 )
132 );
133
134 $this->export->relOnlyTables = array(
135 'sys_file',
136 'sys_file_metadata',
137 'sys_file_storage',
138 'sys_language'
139 );
140
141 $this->export->export_addRecord('pages', BackendUtility::getRecord('pages', 1));
142 $this->export->export_addRecord('pages', BackendUtility::getRecord('pages', 2));
143 $this->export->export_addRecord('tt_content', BackendUtility::getRecord('tt_content', 1));
144 $this->export->export_addRecord('sys_language', BackendUtility::getRecord('sys_language', 1));
145 $this->export->export_addRecord('sys_file_reference', BackendUtility::getRecord('sys_file_reference', 1));
146
147 $this->setPageTree(1, 1);
148
149 // After adding ALL records we set relations:
150 for ($a = 0; $a < 10; $a++) {
151 $addR = $this->export->export_addDBRelations($a);
152 if (!count($addR)) {
153 break;
154 }
155 }
156
157 $this->export->export_addFilesFromRelations();
158 $this->export->export_addFilesFromSysFilesRecords();
159
160 $out = $this->export->compileMemoryToFileContent('xml');
161
162 $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../../Fixtures/ImportExport/pages-and-ttcontent-with-image.xml', $out);
163 }
164
165 }