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