‪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 
20 use PHPUnit\Framework\Attributes\Test;
23 
25 {
26  protected array ‪$pathsToLinkInTestInstance = [
27  'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/fileadmin/user_upload' => 'fileadmin/user_upload',
28  ];
29 
30  protected function ‪setUp(): void
31  {
32  parent::setUp();
33 
34  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/pages.csv');
35  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/tt_content-with-image.csv');
36  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_metadata.csv');
37  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_reference.csv');
38  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_storage.csv');
39  }
40 
41  #[Test]
43  {
44  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file.csv');
45 
46  $subject = $this->getAccessibleMock(Export::class, ['setMetaData']);
48  $out = $subject->render();
49 
50  self::assertFalse($subject->hasErrors());
51 
52  // @todo Use self::assertXmlStringEqualsXmlFile() instead when sqlite issue is sorted out
54  __DIR__ . '/../Fixtures/XmlExports/pages-and-ttcontent-with-image.xml',
55  $out
56  );
57  }
58 
59  #[Test]
61  {
62  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_corrupt.csv');
63 
64  $subject = $this->getAccessibleMock(Export::class, ['setMetaData']);
66  $out = $subject->render();
67 
68  $expectedErrors = [
69  'The SHA-1 file hash of 1:/user_upload/typo3_image2.jpg is not up-to-date in the index! ' .
70  'The file was added based on the current file hash.',
71  ];
72  ‪$errors = $subject->getErrorLog();
73  self::assertSame($expectedErrors, ‪$errors);
74 
75  // @todo Use self::assertXmlStringEqualsXmlFile() instead when sqlite issue is sorted out
77  __DIR__ . '/../Fixtures/XmlExports/pages-and-ttcontent-with-corrupt-image.xml',
78  $out
79  );
80  }
81 
82  #[Test]
84  {
85  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file.csv');
86 
87  $subject = $this->getAccessibleMock(Export::class, ['setMetaData']);
88  $subject->setSaveFilesOutsideExportFile(true);
90  $out = $subject->render();
91 
92  // @todo Use self::assertXmlStringEqualsXmlFile() instead when sqlite issue is sorted out
94  __DIR__ . '/../Fixtures/XmlExports/pages-and-ttcontent-with-image-but-not-included.xml',
95  $out
96  );
97 
98  $temporaryFilesDirectory = $subject->getOrCreateTemporaryFolderName();
99  self::assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', $temporaryFilesDirectory . '/' . 'da9acdf1e105784a57bbffec9520969578287797');
100  }
101 
102  #[Test]
104  {
105  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_invalid_hash.csv');
106 
107  $subject = $this->getAccessibleMock(Export::class, ['setMetaData']);
108  $subject->setSaveFilesOutsideExportFile(true);
110  $out = $subject->render();
111 
112  $expectedErrors = [
113  'The SHA-1 file hash of 1:/user_upload/typo3_image2.jpg is not up-to-date in the index! ' .
114  'The file was added based on the current file hash.',
115  ];
116  ‪$errors = $subject->getErrorLog();
117  self::assertSame($expectedErrors, ‪$errors);
118 
119  // @todo Use self::assertXmlStringEqualsXmlFile() instead when sqlite issue is sorted out
121  __DIR__ . '/../Fixtures/XmlExports/pages-and-ttcontent-with-image-but-not-included.xml',
122  $out
123  );
124 
125  $temporaryFilesDirectory = $subject->getOrCreateTemporaryFolderName();
126  self::assertFileEquals(
127  __DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg',
128  $temporaryFilesDirectory . '/' . 'da9acdf1e105784a57bbffec9520969578287797'
129  );
130  }
131 
136  {
138  [
139  'pages' => [
140  'title',
141  'deleted',
142  'doktype',
143  'hidden',
144  'perms_everybody',
145  ],
146  'tt_content' => [
147  'CType',
148  'header',
149  'header_link',
150  'deleted',
151  'hidden',
152  'image',
153  't3ver_oid',
154  ],
155  'sys_file_reference' => [
156  'uid_local',
157  'uid_foreign',
158  'tablenames',
159  'fieldname',
160  'sorting_foreign',
161  'title',
162  'description',
163  'alternative',
164  'link',
165  ],
166  'sys_file' => [
167  'storage',
168  'type',
169  'metadata',
170  'identifier',
171  'identifier_hash',
172  'folder_hash',
173  'mime_type',
174  'name',
175  'sha1',
176  'size',
177  'creation_date',
178  'modification_date',
179  ],
180  'sys_file_storage' => [
181  'name',
182  'description',
183  'driver',
184  'configuration',
185  'is_default',
186  'is_browsable',
187  'is_public',
188  'is_writable',
189  'is_online',
190  ],
191  'sys_file_metadata' => [
192  'title',
193  'width',
194  'height',
195  'description',
196  'alternative',
197  'file',
198  'sys_language_uid',
199  'l10n_parent',
200  ],
201  ]
202  ;
203 
204  $subject->‪setPid(1);
205  $subject->‪setLevels(1);
206  $subject->‪setTables(['_ALL']);
208  $subject->‪setRelOnlyTables([
209  'sys_file',
210  'sys_file_metadata',
211  'sys_file_storage',
212  ]);
213  $subject->‪process();
214  }
215 }
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest
Definition: PagesAndTtContentWithImagesTest.php:25
‪TYPO3\CMS\Impexp\ImportExport\setPid
‪setPid(int $pid)
Definition: ImportExport.php:1339
‪TYPO3\CMS\Impexp\Export\setRelOnlyTables
‪setRelOnlyTables(array $relOnlyTables)
Definition: Export.php:1358
‪TYPO3\CMS\Impexp\Export\$recordTypesIncludeFields
‪array $recordTypesIncludeFields
Definition: Export.php:87
‪TYPO3\CMS\Impexp\Export\process
‪process()
Definition: Export.php:117
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\exportPagesAndRelatedTtContentWithImagesButNotIncluded
‪exportPagesAndRelatedTtContentWithImagesButNotIncluded()
Definition: PagesAndTtContentWithImagesTest.php:83
‪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:103
‪TYPO3\CMS\Impexp\Export\setRecordTypesIncludeFields
‪setRecordTypesIncludeFields(array $recordTypesIncludeFields)
Definition: Export.php:368
‪TYPO3\CMS\Impexp\Export\setLevels
‪setLevels(int $levels)
Definition: Export.php:1338
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\compileExportPagesAndRelatedTtContentWithImages
‪compileExportPagesAndRelatedTtContentWithImages(Export $subject)
Definition: PagesAndTtContentWithImagesTest.php:135
‪$errors
‪$errors
Definition: annotationChecker.php:116
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\exportPagesAndRelatedTtContentWithImages
‪exportPagesAndRelatedTtContentWithImages()
Definition: PagesAndTtContentWithImagesTest.php:42
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\exportPagesAndRelatedTtContentWithImagesFromCorruptSysFileRecord
‪exportPagesAndRelatedTtContentWithImagesFromCorruptSysFileRecord()
Definition: PagesAndTtContentWithImagesTest.php:60
‪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:52
‪TYPO3\CMS\Impexp\Export\setTables
‪setTables(array $tables)
Definition: Export.php:1348
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\$pathsToLinkInTestInstance
‪array $pathsToLinkInTestInstance
Definition: PagesAndTtContentWithImagesTest.php:26
‪TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\setUp
‪setUp()
Definition: PagesAndTtContentWithImagesTest.php:30