‪TYPO3CMS  ‪main
PagesAndTtContentWithImagesInEmptyDatabaseTest.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;
25 
27 {
28  #[Test]
30  {
31  $subject = GeneralUtility::makeInstance(Import::class);
32  $subject->setPid(0);
33 
34  if (!$this->‪isCaseSensitiveFilesystem()) {
35  self::markTestSkipped('Test not available on case insensitive filesystems.');
36  }
37 
38  $subject->loadFile('EXT:impexp/Tests/Functional/Fixtures/XmlImports/pages-and-ttcontent-with-image.xml');
39  $subject->importData();
40 
41  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg';
42 
43  $this->assertCSVDataSet(__DIR__ . '/../Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithImagesOnCaseSensitiveFilesystems.csv');
44 
45  self::assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg');
46  }
47 
48  #[Test]
50  {
51  $subject = GeneralUtility::makeInstance(Import::class);
52  $subject->setPid(0);
53 
54  if ($this->‪isCaseSensitiveFilesystem()) {
55  self::markTestSkipped('Test not available on case sensitive filesystems.');
56  }
57 
58  $subject->loadFile('EXT:impexp/Tests/Functional/Fixtures/XmlImports/pages-and-ttcontent-with-image.xml');
59  $subject->importData();
60 
61  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg';
62 
63  $this->assertCSVDataSet(__DIR__ . '/../Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithImagesOnCaseInsensitiveFilesystems.csv');
64 
65  self::assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg');
66  }
67 
68  #[Test]
70  {
71  $subject = GeneralUtility::makeInstance(Import::class);
72  $subject->setPid(0);
73 
74  if (!$this->‪isCaseSensitiveFilesystem()) {
75  self::markTestSkipped('Test not available on case insensitive filesystems.');
76  }
77 
78  $subject->loadFile('EXT:impexp/Tests/Functional/Fixtures/XmlImports/pages-and-ttcontent-with-image-without-storage.xml');
79  $subject->importData();
80 
81  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg';
82 
83  $this->assertCSVDataSet(__DIR__ . '/../Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithImagesButWithoutStorageOnCaseSensitiveFilesystems.csv');
84 
85  self::assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg');
86  }
87 
88  #[Test]
90  {
91  $subject = GeneralUtility::makeInstance(Import::class);
92  $subject->setPid(0);
93 
94  if ($this->‪isCaseSensitiveFilesystem()) {
95  self::markTestSkipped('Test not available on case sensitive filesystems.');
96  }
97 
98  $subject->loadFile('EXT:impexp/Tests/Functional/Fixtures/XmlImports/pages-and-ttcontent-with-image-without-storage.xml');
99  $subject->importData();
100 
101  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg';
102 
103  $this->assertCSVDataSet(__DIR__ . '/../Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithImagesButWithoutStorageOnCaseInsensitiveFilesystems.csv');
104 
105  self::assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg');
106  }
107 
108  #[Test]
110  {
111  $subject = GeneralUtility::makeInstance(Import::class);
112  $subject->setPid(0);
113 
114  $subject->loadFile('EXT:impexp/Tests/Functional/Fixtures/XmlImports/pages-and-ttcontent-with-image-with-spaces-in-path.xml');
115  $subject->importData();
116 
117  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/folder_with_spaces/typo3_image2.jpg';
118  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/folder_with_spaces/typo3_image3.jpg';
119 
120  $this->assertCSVDataSet(__DIR__ . '/../Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithImagesWithSpacesInPath.csv');
121 
122  self::assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', ‪Environment::getPublicPath() . '/fileadmin/user_upload/folder_with_spaces/typo3_image2.jpg');
123  self::assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image3.jpg', ‪Environment::getPublicPath() . '/fileadmin/user_upload/folder_with_spaces/typo3_image3.jpg');
124  }
125 
126  #[Test]
128  {
129  $subject = GeneralUtility::makeInstance(Import::class);
130  $subject->setPid(0);
131 
132  // Files are parallel to the fixture .xml file in a folder - impexp tests for /../ not allowed in path, so we set an absolute path here
133  $subject->loadFile('EXT:impexp/Tests/Functional/Fixtures/XmlImports/pages-and-ttcontent-with-image-but-not-included.xml');
134  $subject->importData();
135 
136  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg';
137 
138  $this->assertCSVDataSet(__DIR__ . '/../Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithImagesButNotIncluded.csv');
139 
140  self::assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg');
141  }
142 
143  #[Test]
145  {
146  $subject = GeneralUtility::makeInstance(Import::class);
147  $subject->setPid(0);
148 
149  try {
150  $subject->loadFile('EXT:impexp/Tests/Functional/Fixtures/XmlImports/pages-and-ttcontent-with-image-with-forced-uids.xml');
151  $subject->setForceAllUids(true);
152  $subject->importData();
153  } catch (\‪Exception $e) {
154  }
155 
156  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg';
157 
158  $this->assertCSVDataSet(__DIR__ . '/../Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithImageWithForcedUids.csv');
159 
160  self::assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg');
161 
162  $expectedErrors = [
163  'Forcing uids of sys_file records is not supported! They will be imported as new records!',
164  ];
165  ‪$errors = $subject->getErrorLog();
166  self::assertSame($expectedErrors, ‪$errors);
167  }
168 
169  #[Test]
171  {
172  ‪GeneralUtility::mkdir(‪Environment::getPublicPath() . '/fileadmin_invalid_path');
173 
174  $subject = GeneralUtility::makeInstance(Import::class);
175  $subject->setPid(0);
176  $subject->loadFile('EXT:impexp/Tests/Functional/Fixtures/XmlImports/pages-and-ttcontent-with-image-with-invalid-storage.xml');
177  $subject->importData();
178 
179  self::assertFileEquals(
180  __DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg',
181  ‪Environment::getPublicPath() . '/fileadmin_invalid_path/user_upload/typo3_image2.jpg'
182  );
183  }
184 
185  #[Test]
187  {
188  $subject = GeneralUtility::makeInstance(Import::class);
189  $subject->setPid(0);
190  try {
191  $subject->loadFile('EXT:impexp/Tests/Functional/Fixtures/XmlImports/pages-and-ttcontent-with-missing-image.xml');
192  $subject->importData();
193  } catch (\‪Exception $e) {
194  }
195 
196  $expectedErrors = [
197  'Error: No file found for ID 4a705ca3ef43b53dc00de861ba2c86af',
198  'Error: sys_file_reference record "1" with relation to sys_file record "1", which is not part of the import data, was not imported.',
199  'Lost relation: sys_file_reference:1',
200  'Lost relation: sys_file:1',
201  ];
202  ‪$errors = $subject->getErrorLog();
203  self::assertSame($expectedErrors, ‪$errors);
204  }
205 }
‪TYPO3\CMS\Core\Utility\GeneralUtility\mkdir
‪static bool mkdir(string $newFolder)
Definition: GeneralUtility.php:1638
‪TYPO3\CMS\Core\Exception
Definition: Exception.php:21
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInEmptyDatabaseTest\importPagesAndRelatedTtContentWithImagesButWithoutStorageOnCaseSensitiveFilesystems
‪importPagesAndRelatedTtContentWithImagesButWithoutStorageOnCaseSensitiveFilesystems()
Definition: PagesAndTtContentWithImagesInEmptyDatabaseTest.php:69
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static getPublicPath()
Definition: Environment.php:187
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInEmptyDatabaseTest\importPagesAndRelatedTtContentWithMissingImageRemovesSysFileReferenceToo
‪importPagesAndRelatedTtContentWithMissingImageRemovesSysFileReferenceToo()
Definition: PagesAndTtContentWithImagesInEmptyDatabaseTest.php:186
‪TYPO3\CMS\Impexp\Tests\Functional\Import
Definition: ImagesWithStoragesTest.php:18
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInEmptyDatabaseTest\importPagesAndRelatedTtContentWithImagesAndNewStorage
‪importPagesAndRelatedTtContentWithImagesAndNewStorage()
Definition: PagesAndTtContentWithImagesInEmptyDatabaseTest.php:170
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInEmptyDatabaseTest\importPagesAndRelatedTtContentWithImagesWithSpacesInPath
‪importPagesAndRelatedTtContentWithImagesWithSpacesInPath()
Definition: PagesAndTtContentWithImagesInEmptyDatabaseTest.php:109
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInEmptyDatabaseTest
Definition: PagesAndTtContentWithImagesInEmptyDatabaseTest.php:27
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInEmptyDatabaseTest\importPagesAndRelatedTtContentWithImagesButNotIncluded
‪importPagesAndRelatedTtContentWithImagesButNotIncluded()
Definition: PagesAndTtContentWithImagesInEmptyDatabaseTest.php:127
‪TYPO3\CMS\Impexp\Import
Definition: Import.php:51
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInEmptyDatabaseTest\importPagesAndRelatedTtContentWithImagesOnCaseInsensitiveFilesystems
‪importPagesAndRelatedTtContentWithImagesOnCaseInsensitiveFilesystems()
Definition: PagesAndTtContentWithImagesInEmptyDatabaseTest.php:49
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInEmptyDatabaseTest\importPagesAndRelatedTtContentWithImageWithForcedUids
‪importPagesAndRelatedTtContentWithImageWithForcedUids()
Definition: PagesAndTtContentWithImagesInEmptyDatabaseTest.php:144
‪$errors
‪$errors
Definition: annotationChecker.php:116
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInEmptyDatabaseTest\importPagesAndRelatedTtContentWithImagesOnCaseSensitiveFilesystems
‪importPagesAndRelatedTtContentWithImagesOnCaseSensitiveFilesystems()
Definition: PagesAndTtContentWithImagesInEmptyDatabaseTest.php:29
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase
Definition: AbstractImportExportTestCase.php:33
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInEmptyDatabaseTest\importPagesAndRelatedTtContentWithImagesButWithoutStorageOnCaseInsensitiveFilesystems
‪importPagesAndRelatedTtContentWithImagesButWithoutStorageOnCaseInsensitiveFilesystems()
Definition: PagesAndTtContentWithImagesInEmptyDatabaseTest.php:89
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\isCaseSensitiveFilesystem
‪isCaseSensitiveFilesystem()
Definition: AbstractImportExportTestCase.php:74