‪TYPO3CMS  9.5
GroupFileAndFileReferenceItemTest.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 
22 
27 {
31  protected ‪$testExtensionsToLoad = [
32  'typo3/sysext/impexp/Tests/Functional/Fixtures/Extensions/impexp_group_files'
33  ];
34 
38  protected ‪$pathsToLinkInTestInstance = [
39  'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/fileadmin/user_upload' => 'fileadmin/user_upload',
40  'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/uploads/tx_impexpgroupfiles' => 'uploads/tx_impexpgroupfiles'
41  ];
42 
43  protected function ‪setUp()
44  {
45  parent::setUp();
46 
47  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/pages.xml');
48  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file.xml');
49  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_storage.xml');
50  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/tx_impexpgroupfiles_item.xml');
51  }
52 
57  {
58  $subject = GeneralUtility::makeInstance(Export::class);
59  $subject->init();
60 
62 
63  $out = $subject->compileMemoryToFileContent('xml');
64 
65  $this->assertXmlStringEqualsXmlFile(
66  __DIR__ . '/../Fixtures/XmlExports/impexp-group-file-and-file_reference-item.xml',
67  $out
68  );
69  }
70 
75  {
76  $subject = GeneralUtility::makeInstance(Export::class);
77  $subject->init();
78 
79  $subject->setSaveFilesOutsideExportFile(true);
80 
82 
83  $out = $subject->compileMemoryToFileContent('xml');
84 
85  $this->assertXmlStringEqualsXmlFile(
86  __DIR__ . '/../Fixtures/XmlExports/impexp-group-file-and-file_reference-item-but-images-not-included.xml',
87  $out
88  );
89 
90  $temporaryFilesDirectory = $subject->getTemporaryFilesPathForExport();
91  $this->assertFileEquals(__DIR__ . '/../Fixtures/Folders/uploads/tx_impexpgroupfiles/typo3_image4.jpg', $temporaryFilesDirectory . 'e1c5c4e1e34e19e2facb438752e06c3f');
92  $this->assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image5.jpg', $temporaryFilesDirectory . 'c3511df85d21bc578faf71c6a19eeb3ff44af370');
93  }
94 
100  protected function ‪compileExportGroupFileAndFileReferenceItem(‪Export $subject)
101  {
103  [
104  'pages' => [
105  'title',
106  'deleted',
107  'doktype',
108  'hidden',
109  'perms_everybody'
110  ],
111  'sys_file' => [
112  'storage',
113  'type',
114  'metadata',
115  'extension',
116  'identifier',
117  'identifier_hash',
118  'folder_hash',
119  'mime_type',
120  'name',
121  'sha1',
122  'size',
123  'creation_date',
124  'modification_date',
125  ],
126  'sys_file_storage' => [
127  'name',
128  'description',
129  'driver',
130  'configuration',
131  'is_default',
132  'is_browsable',
133  'is_public',
134  'is_writable',
135  'is_online'
136  ],
137  'tx_impexpgroupfiles_item' => [
138  'title',
139  'deleted',
140  'hidden',
141  'images',
142  'image_references'
143  ],
144 
145  ]
146  );
147 
148  $subject->relOnlyTables = [
149  'sys_file',
150  'sys_file_storage'
151  ];
152 
153  // @todo: Do not rely on BackendUtility::getRecord() in the test case itself
154  $subject->‪export_addRecord('pages', $this->‪forceStringsOnRowValues(‪BackendUtility::getRecord('pages', 1)));
155  $subject->‪export_addRecord('tx_impexpgroupfiles_item', $this->‪forceStringsOnRowValues(‪BackendUtility::getRecord('tx_impexpgroupfiles_item', 1)));
156 
157  $this->‪setPageTree($subject, 1, 0);
158 
159  // After adding ALL records we set relations:
160  for ($a = 0; $a < 10; $a++) {
161  $addR = $subject->‪export_addDBRelations($a);
162  if (empty($addR)) {
163  break;
164  }
165  }
166 
167  // Hacky, but the timestamp will change on every clone, so set the file modification timestamp to the asserted value
168  $success = touch(‪Environment::getPublicPath() . '/uploads/tx_impexpgroupfiles/typo3_image4.jpg', 1393866824);
169  // Early fail if touching failed - indicates a broken functional test setup
170  $this->assertTrue($success, 'Could not set file modification timestamp for a fixture binary file.');
171 
174  }
175 }
‪TYPO3\CMS\Impexp\Export\export_addFilesFromSysFilesRecords
‪export_addFilesFromSysFilesRecords()
Definition: Export.php:635
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:153
‪TYPO3\CMS\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItemTest\exportGroupFileAndFileReferenceItemButImagesNotIncluded
‪exportGroupFileAndFileReferenceItemButImagesNotIncluded()
Definition: GroupFileAndFileReferenceItemTest.php:72
‪TYPO3\CMS\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItemTest\$pathsToLinkInTestInstance
‪array $pathsToLinkInTestInstance
Definition: GroupFileAndFileReferenceItemTest.php:36
‪TYPO3\CMS\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItemTest\exportGroupFileAndFileReferenceItem
‪exportGroupFileAndFileReferenceItem()
Definition: GroupFileAndFileReferenceItemTest.php:54
‪TYPO3\CMS\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItemTest\compileExportGroupFileAndFileReferenceItem
‪compileExportGroupFileAndFileReferenceItem(Export $subject)
Definition: GroupFileAndFileReferenceItemTest.php:98
‪TYPO3\CMS\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItemTest\setUp
‪setUp()
Definition: GroupFileAndFileReferenceItemTest.php:41
‪TYPO3\CMS\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItemTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: GroupFileAndFileReferenceItemTest.php:30
‪TYPO3\CMS\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItemTest
Definition: GroupFileAndFileReferenceItemTest.php:27
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\setPageTree
‪setPageTree(Export $export, $pidToStart, $depth=1)
Definition: AbstractImportExportTestCase.php:80
‪TYPO3\CMS\Impexp\Export\setRecordTypesIncludeFields
‪setRecordTypesIncludeFields(array $recordTypesIncludeFields)
Definition: Export.php:260
‪TYPO3\CMS\Impexp\Export\export_addDBRelations
‪array export_addDBRelations($relationLevel=0)
Definition: Export.php:422
‪TYPO3\CMS\Impexp\Export\export_addFilesFromRelations
‪export_addFilesFromRelations()
Definition: Export.php:546
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪TYPO3\CMS\Impexp\Export\export_addRecord
‪export_addRecord($table, $row, $relationLevel=0)
Definition: Export.php:289
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecord
‪static array null getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
Definition: BackendUtility.php:130
‪TYPO3\CMS\Impexp\Tests\Functional\Export
Definition: GroupFileAndFileReferenceItemInFlexFormTest.php:2
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase
Definition: AbstractImportExportTestCase.php:30
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\forceStringsOnRowValues
‪array forceStringsOnRowValues(array $row)
Definition: AbstractImportExportTestCase.php:155
‪TYPO3\CMS\Impexp\Export
Definition: Export.php:62
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45