TYPO3 CMS  TYPO3_7-6
ExportTest.php
Go to the documentation of this file.
1 <?php
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 
18 
23 {
27  protected $testExtensionsToLoad = [
28  'typo3/sysext/impexp/Tests/Functional/Fixtures/Extensions/impexp_group_files'
29  ];
30 
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  {
41  parent::setUp();
42 
43  $this->importDataSet(__DIR__ . '/../../Fixtures/Database/pages.xml');
44  $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file.xml');
45  $this->importDataSet(__DIR__ . '/../../Fixtures/Database/sys_file_storage.xml');
46  $this->importDataSet(__DIR__ . '/../../Fixtures/Database/tx_impexpgroupfiles_item.xml');
47  }
48 
53  {
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 
65  {
66  $this->export->setSaveFilesOutsideExportFile(true);
67 
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 
80  {
81  $this->export->setRecordTypesIncludeFields(
82  [
83  'pages' => [
84  'title',
85  'deleted',
86  'doktype',
87  'hidden',
88  'perms_everybody'
89  ],
90  'sys_file' => [
91  'storage',
92  'type',
93  'metadata',
94  'extension',
95  'identifier',
96  'identifier_hash',
97  'folder_hash',
98  'mime_type',
99  'name',
100  'sha1',
101  'size',
102  'creation_date',
103  'modification_date',
104  ],
105  'sys_file_storage' => [
106  'name',
107  'description',
108  'driver',
109  'configuration',
110  'is_default',
111  'is_browsable',
112  'is_public',
113  'is_writable',
114  'is_online'
115  ],
116  'tx_impexpgroupfiles_item' => [
117  'title',
118  'deleted',
119  'hidden',
120  'images',
121  'image_references'
122  ],
123 
124  ]
125  );
126 
127  $this->export->relOnlyTables = [
128  'sys_file',
129  'sys_file_storage'
130  ];
131 
132  $this->export->export_addRecord('pages', BackendUtility::getRecord('pages', 1));
133  $this->export->export_addRecord('tx_impexpgroupfiles_item', BackendUtility::getRecord('tx_impexpgroupfiles_item', 1));
134 
135  $this->setPageTree(1, 0);
136 
137  // After adding ALL records we set relations:
138  for ($a = 0; $a < 10; $a++) {
139  $addR = $this->export->export_addDBRelations($a);
140  if (empty($addR)) {
141  break;
142  }
143  }
144 
145  // hacky, but the timestamp will change on every clone, so set the file
146  // modification timestamp to the asserted value
147  $success = @touch(PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg', 1393866824);
148  if (!$success) {
149  $this->markTestSkipped('Could not set file modification timestamp for a fixture binary file. This is required for running the test successful.');
150  }
151 
152  $this->export->export_addFilesFromRelations();
153  $this->export->export_addFilesFromSysFilesRecords();
154  }
155 }
static getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)