‪TYPO3CMS  ‪main
PagesAndTtContentWithImagesTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 
24 {
25  protected array ‪$pathsToLinkInTestInstance = [
26  'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/fileadmin/user_upload' => 'fileadmin/user_upload',
27  ];
28 
29  protected function ‪setUp(): void
30  {
31  parent::setUp();
32 
33  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/pages.csv');
34  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/tt_content-with-image.csv');
35  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_metadata.csv');
36  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_reference.csv');
37  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_storage.csv');
38  }
39 
44  {
45  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file.csv');
46 
47  $subject = $this->getAccessibleMock(Export::class, ['setMetaData']);
49  $out = $subject->render();
50 
51  self::assertFalse($subject->hasErrors());
52 
53  // @todo Use self::assertXmlStringEqualsXmlFile() instead when sqlite issue is sorted out
55  __DIR__ . '/../Fixtures/XmlExports/pages-and-ttcontent-with-image.xml',
56  $out
57  );
58  }
59 
64  {
65  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_corrupt.csv');
66 
67  $subject = $this->getAccessibleMock(Export::class, ['setMetaData']);
69  $out = $subject->render();
70 
71  $expectedErrors = [
72  'The SHA-1 file hash of 1:/user_upload/typo3_image2.jpg is not up-to-date in the index! ' .
73  'The file was added based on the current file hash.',
74  ];
75  ‪$errors = $subject->getErrorLog();
76  self::assertSame($expectedErrors, ‪$errors);
77 
78  // @todo Use self::assertXmlStringEqualsXmlFile() instead when sqlite issue is sorted out
80  __DIR__ . '/../Fixtures/XmlExports/pages-and-ttcontent-with-corrupt-image.xml',
81  $out
82  );
83  }
84 
89  {
90  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file.csv');
91 
92  $subject = $this->getAccessibleMock(Export::class, ['setMetaData']);
93  $subject->setSaveFilesOutsideExportFile(true);
95  $out = $subject->render();
96 
97  // @todo Use self::assertXmlStringEqualsXmlFile() instead when sqlite issue is sorted out
99  __DIR__ . '/../Fixtures/XmlExports/pages-and-ttcontent-with-image-but-not-included.xml',
100  $out
101  );
102 
103  $temporaryFilesDirectory = $subject->getOrCreateTemporaryFolderName();
104  self::assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', $temporaryFilesDirectory . '/' . 'da9acdf1e105784a57bbffec9520969578287797');
105  }
106 
111  {
112  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_invalid_hash.csv');
113 
114  $subject = $this->getAccessibleMock(Export::class, ['setMetaData']);
115  $subject->setSaveFilesOutsideExportFile(true);
117  $out = $subject->render();
118 
119  $expectedErrors = [
120  'The SHA-1 file hash of 1:/user_upload/typo3_image2.jpg is not up-to-date in the index! ' .
121  'The file was added based on the current file hash.',
122  ];
123  ‪$errors = $subject->getErrorLog();
124  self::assertSame($expectedErrors, ‪$errors);
125 
126  // @todo Use self::assertXmlStringEqualsXmlFile() instead when sqlite issue is sorted out
128  __DIR__ . '/../Fixtures/XmlExports/pages-and-ttcontent-with-image-but-not-included.xml',
129  $out
130  );
131 
132  $temporaryFilesDirectory = $subject->getOrCreateTemporaryFolderName();
133  self::assertFileEquals(
134  __DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg',
135  $temporaryFilesDirectory . '/' . 'da9acdf1e105784a57bbffec9520969578287797'
136  );
137  }
138 
143  {
145  [
146  'pages' => [
147  'title',
148  'deleted',
149  'doktype',
150  'hidden',
151  'perms_everybody',
152  ],
153  'tt_content' => [
154  'CType',
155  'header',
156  'header_link',
157  'deleted',
158  'hidden',
159  'image',
160  't3ver_oid',
161  ],
162  'sys_file_reference' => [
163  'uid_local',
164  'uid_foreign',
165  'tablenames',
166  'fieldname',
167  'sorting_foreign',
168  'title',
169  'description',
170  'alternative',
171  'link',
172  ],
173  'sys_file' => [
174  'storage',
175  'type',
176  'metadata',
177  'identifier',
178  'identifier_hash',
179  'folder_hash',
180  'mime_type',
181  'name',
182  'sha1',
183  'size',
184  'creation_date',
185  'modification_date',
186  ],
187  'sys_file_storage' => [
188  'name',
189  'description',
190  'driver',
191  'configuration',
192  'is_default',
193  'is_browsable',
194  'is_public',
195  'is_writable',
196  'is_online',
197  ],
198  'sys_file_metadata' => [
199  'title',
200  'width',
201  'height',
202  'description',
203  'alternative',
204  'file',
205  'sys_language_uid',
206  'l10n_parent',
207  ],
208  ]
209  ;
210 
211  $subject->‪setPid(1);
212  $subject->‪setLevels(1);
213  $subject->‪setTables(['_ALL']);
215  $subject->‪setRelOnlyTables([
216  'sys_file',
217  'sys_file_metadata',
218  'sys_file_storage',
219  ]);
220  $subject->‪process();
221  }
222 }
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest
Definition: PagesAndTtContentWithImagesTest.php:24
‪TYPO3\CMS\Impexp\ImportExport\setPid
‪setPid(int $pid)
Definition: ImportExport.php:1490
‪TYPO3\CMS\Impexp\Export\setRelOnlyTables
‪setRelOnlyTables(array $relOnlyTables)
Definition: Export.php:1524
‪TYPO3\CMS\Impexp\Export\$recordTypesIncludeFields
‪array $recordTypesIncludeFields
Definition: Export.php:124
‪TYPO3\CMS\Impexp\Export\process
‪process()
Definition: Export.php:174
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\exportPagesAndRelatedTtContentWithImagesButNotIncluded
‪exportPagesAndRelatedTtContentWithImagesButNotIncluded()
Definition: PagesAndTtContentWithImagesTest.php:88
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\assertXmlStringEqualsXmlFileWithIgnoredSqliteTypeInteger
‪assertXmlStringEqualsXmlFileWithIgnoredSqliteTypeInteger(string $expectedFile, string $actualXml)
Definition: AbstractImportExportTestCase.php:92
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\exportPagesAndRelatedTtContentWithImagesButNotIncludedAndInvalidHash
‪exportPagesAndRelatedTtContentWithImagesButNotIncludedAndInvalidHash()
Definition: PagesAndTtContentWithImagesTest.php:110
‪TYPO3\CMS\Impexp\Export\setRecordTypesIncludeFields
‪setRecordTypesIncludeFields(array $recordTypesIncludeFields)
Definition: Export.php:435
‪TYPO3\CMS\Impexp\Export\setLevels
‪setLevels(int $levels)
Definition: Export.php:1504
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\compileExportPagesAndRelatedTtContentWithImages
‪compileExportPagesAndRelatedTtContentWithImages(Export $subject)
Definition: PagesAndTtContentWithImagesTest.php:142
‪$errors
‪$errors
Definition: annotationChecker.php:121
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\exportPagesAndRelatedTtContentWithImages
‪exportPagesAndRelatedTtContentWithImages()
Definition: PagesAndTtContentWithImagesTest.php:43
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\exportPagesAndRelatedTtContentWithImagesFromCorruptSysFileRecord
‪exportPagesAndRelatedTtContentWithImagesFromCorruptSysFileRecord()
Definition: PagesAndTtContentWithImagesTest.php:63
‪TYPO3\CMS\Impexp\Tests\Functional\Export
Definition: IrreRecordsTest.php:18
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase
Definition: AbstractImportExportTestCase.php:33
‪TYPO3\CMS\Impexp\Export
Definition: Export.php:53
‪TYPO3\CMS\Impexp\Export\setTables
‪setTables(array $tables)
Definition: Export.php:1514
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\$pathsToLinkInTestInstance
‪array $pathsToLinkInTestInstance
Definition: PagesAndTtContentWithImagesTest.php:25
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\setUp
‪setUp()
Definition: PagesAndTtContentWithImagesTest.php:29