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  {
54  $this->export->setRecordTypesIncludeFields(
55  [
56  'pages' => [
57  'title',
58  'deleted',
59  'doktype',
60  'hidden',
61  'perms_everybody'
62  ],
63  'sys_file' => [
64  'storage',
65  'type',
66  'metadata',
67  'extension',
68  'identifier',
69  'identifier_hash',
70  'folder_hash',
71  'mime_type',
72  'name',
73  'sha1',
74  'size',
75  'creation_date',
76  'modification_date',
77  ],
78  'sys_file_storage' => [
79  'name',
80  'description',
81  'driver',
82  'configuration',
83  'is_default',
84  'is_browsable',
85  'is_public',
86  'is_writable',
87  'is_online'
88  ],
89  'tx_impexpgroupfiles_item' => [
90  'title',
91  'deleted',
92  'hidden',
93  'images',
94  'image_references',
95  'flexform'
96  ],
97 
98  ]
99  );
100 
101  $this->export->relOnlyTables = [
102  'sys_file',
103  'sys_file_storage'
104  ];
105 
106  $this->export->export_addRecord('pages', BackendUtility::getRecord('pages', 2));
107  $this->export->export_addRecord('tx_impexpgroupfiles_item', BackendUtility::getRecord('tx_impexpgroupfiles_item', 2));
108 
109  $this->setPageTree(2, 0);
110 
111  // After adding ALL records we set relations:
112  for ($a = 0; $a < 10; $a++) {
113  $addR = $this->export->export_addDBRelations($a);
114  if (empty($addR)) {
115  break;
116  }
117  }
118 
119  // hacky, but the timestamp will change on every clone, so set the file
120  // modification timestamp to the asserted value
121  $success = @touch(PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg', 1393866824);
122  if (!$success) {
123  $this->markTestSkipped('Could not set file modification timestamp for a fixture binary file. This is required for running the test successful.');
124  }
125 
126  $this->export->export_addFilesFromRelations();
127  $this->export->export_addFilesFromSysFilesRecords();
128 
129  $out = $this->export->compileMemoryToFileContent('xml');
130 
131  $this->assertXmlStringEqualsXmlFile(__DIR__ . '/../../Fixtures/ImportExportXml/impexp-group-file-and-file_reference-item-in-ff.xml', $out);
132  }
133 }
static getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)