‪TYPO3CMS  9.5
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 
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 
61  $subject->setRecordTypesIncludeFields(
62  [
63  'pages' => [
64  'title',
65  'deleted',
66  'doktype',
67  'hidden',
68  'perms_everybody'
69  ],
70  'sys_file' => [
71  'storage',
72  'type',
73  'metadata',
74  'extension',
75  'identifier',
76  'identifier_hash',
77  'folder_hash',
78  'mime_type',
79  'name',
80  'sha1',
81  'size',
82  'creation_date',
83  'modification_date',
84  ],
85  'sys_file_storage' => [
86  'name',
87  'description',
88  'driver',
89  'configuration',
90  'is_default',
91  'is_browsable',
92  'is_public',
93  'is_writable',
94  'is_online'
95  ],
96  'tx_impexpgroupfiles_item' => [
97  'title',
98  'deleted',
99  'hidden',
100  'images',
101  'image_references',
102  'flexform'
103  ],
104 
105  ]
106  );
107 
108  $subject->relOnlyTables = [
109  'sys_file',
110  'sys_file_storage'
111  ];
112 
113  // @todo: Do not rely on BackendUtility::getRecord() in the test case itself
114  $subject->export_addRecord('pages', $this->‪forceStringsOnRowValues(‪BackendUtility::getRecord('pages', 2)));
115  $subject->export_addRecord('tx_impexpgroupfiles_item', $this->‪forceStringsOnRowValues(‪BackendUtility::getRecord('tx_impexpgroupfiles_item', 2)));
116 
117  $this->‪setPageTree($subject, 2, 0);
118 
119  // After adding ALL records we set relations:
120  for ($a = 0; $a < 10; $a++) {
121  $addR = $subject->export_addDBRelations($a);
122  if (empty($addR)) {
123  break;
124  }
125  }
126 
127  // Hacky, but the timestamp will change on every clone, so set the file modification timestamp to the asserted value
128  $success = touch(‪Environment::getPublicPath() . '/uploads/tx_impexpgroupfiles/typo3_image4.jpg', 1393866824);
129  // Early fail if touching failed - indicates a broken functional test setup
130  $this->assertTrue($success, 'Could not set file modification timestamp for a fixture binary file.');
131 
132  $subject->export_addFilesFromRelations();
133  $subject->export_addFilesFromSysFilesRecords();
134 
135  $out = $subject->compileMemoryToFileContent('xml');
136 
137  $this->assertXmlStringEqualsXmlFile(
138  __DIR__ . '/../Fixtures/XmlExports/impexp-group-file-and-file_reference-item-in-ff.xml',
139  $out
140  );
141  }
142 }
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:153
‪TYPO3\CMS\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItemInFlexFormTest\setUp
‪setUp()
Definition: GroupFileAndFileReferenceItemInFlexFormTest.php:41
‪TYPO3\CMS\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItemInFlexFormTest\$pathsToLinkInTestInstance
‪array $pathsToLinkInTestInstance
Definition: GroupFileAndFileReferenceItemInFlexFormTest.php:36
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\setPageTree
‪setPageTree(Export $export, $pidToStart, $depth=1)
Definition: AbstractImportExportTestCase.php:80
‪TYPO3\CMS\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItemInFlexFormTest\exportGroupFileAndFileReferenceItem
‪exportGroupFileAndFileReferenceItem()
Definition: GroupFileAndFileReferenceItemInFlexFormTest.php:54
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪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\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItemInFlexFormTest
Definition: GroupFileAndFileReferenceItemInFlexFormTest.php:27
‪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
‪TYPO3\CMS\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItemInFlexFormTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: GroupFileAndFileReferenceItemInFlexFormTest.php:30