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