168562dd6bea6a57abde4c097d668c4b0134c7e5
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / Tests / Functional / Export / GroupFileAndFileReferenceItem / ExportTest.php
1 <?php
2 namespace TYPO3\CMS\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItem;
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 require_once __DIR__ . '/../AbstractExportTestCase.php';
20
21 /**
22 * Functional test for the ImportExport
23 */
24 class ExportTest extends \TYPO3\CMS\Impexp\Tests\Functional\Export\AbstractExportTestCase {
25
26 /**
27 * @var array
28 */
29 protected $testExtensionsToLoad = array(
30 'typo3/sysext/impexp/Tests/Functional/Fixtures/Extensions/impexp_group_files'
31 );
32
33 /**
34 * @var array
35 */
36 protected $pathsToLinkInTestInstance = array(
37 'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/fileadmin/user_upload' => 'fileadmin/user_upload',
38 'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/uploads/tx_impexpgroupfiles' => 'uploads/tx_impexpgroupfiles'
39 );
40
41 protected function setUp() {
42 parent::setUp();
43
44 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/pages.xml');
45 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file.xml');
46 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file_storage.xml');
47 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/tx_impexpgroupfiles_item.xml');
48
49 }
50
51 /**
52 * @test
53 */
54 public function exportGroupFileAndFileReferenceItem() {
55
56 $this->compileExportGroupFileAndFileReferenceItem();
57
58 $out = $this->export->compileMemoryToFileContent('xml');
59
60 $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../../Fixtures/ImportExportXml/impexp-group-file-and-file_reference-item.xml', $out);
61 }
62
63 /**
64 * @test
65 */
66 public function exportGroupFileAndFileReferenceItemButImagesNotIncluded() {
67
68 $this->export->setSaveFilesOutsideExportFile(TRUE);
69
70 $this->compileExportGroupFileAndFileReferenceItem();
71
72 $out = $this->export->compileMemoryToFileContent('xml');
73
74 $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../../Fixtures/ImportExportXml/impexp-group-file-and-file_reference-item-but-images-not-included.xml', $out);
75
76 $temporaryFilesDirectory = $this->export->getTemporaryFilesPathForExport();
77 $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/uploads/tx_impexpgroupfiles/typo3_image4.jpg', $temporaryFilesDirectory . 'e1c5c4e1e34e19e2facb438752e06c3f');
78 $this->assertFileEquals(__DIR__ . '/../../Fixtures/Folders/fileadmin/user_upload/typo3_image5.jpg', $temporaryFilesDirectory . 'c3511df85d21bc578faf71c6a19eeb3ff44af370');
79 }
80
81
82
83
84 protected function compileExportGroupFileAndFileReferenceItem() {
85
86 $this->export->setRecordTypesIncludeFields(
87 array(
88 'pages' => array(
89 'title',
90 'deleted',
91 'doktype',
92 'hidden',
93 'perms_everybody'
94 ),
95 'sys_file' => array(
96 'storage',
97 'type',
98 'metadata',
99 'extension',
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 'tx_impexpgroupfiles_item' => array(
122 'title',
123 'deleted',
124 'hidden',
125 'images',
126 'image_references'
127 ),
128
129 )
130 );
131
132 $this->export->relOnlyTables = array(
133 'sys_file',
134 'sys_file_storage'
135 );
136
137 $this->export->export_addRecord('pages', BackendUtility::getRecord('pages', 1));
138 $this->export->export_addRecord('tx_impexpgroupfiles_item', BackendUtility::getRecord('tx_impexpgroupfiles_item', 1));
139
140 $this->setPageTree(1, 0);
141
142 // After adding ALL records we set relations:
143 for ($a = 0; $a < 10; $a++) {
144 $addR = $this->export->export_addDBRelations($a);
145 if (!count($addR)) {
146 break;
147 }
148 }
149
150 // hacky, but the timestamp will change on every clone, so set the file
151 // modification timestamp to the asserted value
152 $success = @touch(PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg', 1393866824);
153 if (!$success) {
154 $this->markTestSkipped('Could not set file modification timestamp for a fixture binary file. This is required for running the test successful.');
155 }
156
157 $this->export->export_addFilesFromRelations();
158 $this->export->export_addFilesFromSysFilesRecords();
159
160 }
161
162 }