[BUGFIX] Fix import of type group internal_type file_reference
[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 * 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 * @var array
38 */
39 protected $testExtensionsToLoad = array(
40 'typo3/sysext/impexp/Tests/Functional/Fixtures/Extensions/impexp_group_files'
41 );
42
43 /**
44 * @var array
45 */
46 protected $pathsToLinkInTestInstance = array(
47 'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/fileadmin/user_upload' => 'fileadmin/user_upload',
48 'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/uploads/tx_impexpgroupfiles' => 'uploads/tx_impexpgroupfiles'
49 );
50
51 public function setUp() {
52 parent::setUp();
53
54 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/pages.xml');
55 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file.xml');
56 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file_storage.xml');
57 $this->importDataSet(__DIR__ . '/../../Fixtures/Database/tx_impexpgroupfiles_item.xml');
58
59 }
60
61 /**
62 * @test
63 */
64 public function exportGroupFileAndFileReferenceItem() {
65
66 $this->export->setRecordTypesIncludeFields(
67 array(
68 'pages' => array(
69 'title',
70 'deleted',
71 'doktype',
72 'hidden',
73 'perms_everybody'
74 ),
75 'sys_file' => array(
76 'storage',
77 'type',
78 'metadata',
79 'extension',
80 'identifier',
81 'identifier_hash',
82 'folder_hash',
83 'mime_type',
84 'name',
85 'sha1',
86 'size',
87 'creation_date',
88 'modification_date',
89 ),
90 'sys_file_storage' => array(
91 'name',
92 'description',
93 'driver',
94 'configuration',
95 'is_default',
96 'is_browsable',
97 'is_public',
98 'is_writable',
99 'is_online'
100 ),
101 'tx_impexpgroupfiles_item' => array(
102 'title',
103 'deleted',
104 'hidden',
105 'images',
106 'image_references'
107 ),
108
109 )
110 );
111
112 $this->export->relOnlyTables = array(
113 'sys_file',
114 'sys_file_storage'
115 );
116
117 $this->export->export_addRecord('pages', BackendUtility::getRecord('pages', 1));
118 $this->export->export_addRecord('tx_impexpgroupfiles_item', BackendUtility::getRecord('tx_impexpgroupfiles_item', 1));
119
120 $this->setPageTree(1, 0);
121
122 // After adding ALL records we set relations:
123 for ($a = 0; $a < 10; $a++) {
124 $addR = $this->export->export_addDBRelations($a);
125 if (!count($addR)) {
126 break;
127 }
128 }
129
130 // hacky, but the timestamp will change on every clone, so set the file
131 // modification timestamp to the asserted value
132 $success = @touch(PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg', 1393866824);
133 if (!$success) {
134 $this->markTestSkipped('Could not set file modification timestamp for a fixture binary file. This is required for running the test successful.');
135 }
136
137 $this->export->export_addFilesFromRelations();
138 $this->export->export_addFilesFromSysFilesRecords();
139
140 $out = $this->export->compileMemoryToFileContent('xml');
141
142 $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../../Fixtures/ImportExportXml/impexp-group-file-and-file_reference-item.xml', $out);
143 }
144
145 }