TYPO3 CMS  TYPO3_8-7
GroupFileAndFileReferenceItemInFlexFormTest.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 
21 
26 {
30  protected $testExtensionsToLoad = [
31  'typo3/sysext/impexp/Tests/Functional/Fixtures/Extensions/impexp_group_files'
32  ];
33 
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 
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  $subject->export_addRecord('pages', BackendUtility::getRecord('pages', 2));
113  $subject->export_addRecord('tx_impexpgroupfiles_item', BackendUtility::getRecord('tx_impexpgroupfiles_item', 2));
114 
115  $this->setPageTree($subject, 2, 0);
116 
117  // After adding ALL records we set relations:
118  for ($a = 0; $a < 10; $a++) {
119  $addR = $subject->export_addDBRelations($a);
120  if (empty($addR)) {
121  break;
122  }
123  }
124 
125  // hacky, but the timestamp will change on every clone, so set the file
126  // modification timestamp to the asserted value
127  $success = @touch(PATH_site . 'uploads/tx_impexpgroupfiles/typo3_image4.jpg', 1393866824);
128  if (!$success) {
129  $this->markTestSkipped('Could not set file modification timestamp for a fixture binary file. This is required for running the test successful.');
130  }
131 
132  $subject->export_addFilesFromRelations();
133  $subject->export_addFilesFromSysFilesRecords();
134 
135  $out = $subject->compileMemoryToFileContent('xml');
136 
137  $this->assertXmlStringEqualsXmlFile(
138  __DIR__ . '/../Fixtures/XmlExports/' . $this->databasePlatform . '/impexp-group-file-and-file_reference-item-in-ff.xml',
139  $out
140  );
141  }
142 }
static makeInstance($className,... $constructorArguments)
static getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)