f881fdbd4c9021a34d81723a27ed029bcf31ca7c
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / Tests / Functional / Import / PagesAndTtContentWithImagesInEmptyDatabaseTest.php
1 <?php
2 namespace TYPO3\CMS\Impexp\Tests\Functional\Import;
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
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18 use TYPO3\CMS\Impexp\Import;
19 use TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase;
20
21 /**
22 * Test case
23 */
24 class PagesAndTtContentWithImagesInEmptyDatabaseTest extends AbstractImportExportTestCase
25 {
26 /**
27 * @test
28 */
29 public function importPagesAndRelatedTtContentWithImagesOnCaseSensitiveFilesystems()
30 {
31 $subject = GeneralUtility::makeInstance(Import::class);
32 $subject->init();
33
34 if (!$this->isCaseSensitiveFilesystem()) {
35 $this->markTestSkipped('Test not available on case insensitive filesystems.');
36 }
37
38 $subject->loadFile(
39 __DIR__ . '/../Fixtures/XmlImports/pages-and-ttcontent-with-image.xml',
40 1
41 );
42 $subject->importData(0);
43
44 $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/typo3_image2.jpg';
45
46 $this->assertCSVDataSet('EXT:impexp/Tests/Functional/Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithImagesOnCaseSensitiveFilesystems.csv');
47
48 $this->assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', PATH_site . 'fileadmin/user_upload/typo3_image2.jpg');
49 }
50
51 /**
52 * @test
53 */
54 public function importPagesAndRelatedTtContentWithImagesOnCaseInsensitiveFilesystems()
55 {
56 $subject = GeneralUtility::makeInstance(Import::class);
57 $subject->init();
58
59 if ($this->isCaseSensitiveFilesystem()) {
60 $this->markTestSkipped('Test not available on case sensitive filesystems.');
61 }
62
63 $subject->loadFile(
64 __DIR__ . '/../Fixtures/XmlImports/pages-and-ttcontent-with-image.xml',
65 1
66 );
67 $subject->importData(0);
68
69 $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/typo3_image2.jpg';
70
71 $this->assertCSVDataSet('EXT:impexp/Tests/Functional/Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithImagesOnCaseInsensitiveFilesystems.csv');
72
73 $this->assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', PATH_site . 'fileadmin/user_upload/typo3_image2.jpg');
74 }
75
76 /**
77 * @test
78 */
79 public function importPagesAndRelatedTtContentWithImagesButWithoutStorageOnCaseSensitiveFilesystems()
80 {
81 $subject = GeneralUtility::makeInstance(Import::class);
82 $subject->init();
83
84 if (!$this->isCaseSensitiveFilesystem()) {
85 $this->markTestSkipped('Test not available on case insensitive filesystems.');
86 }
87
88 $subject->loadFile(
89 __DIR__ . '/../Fixtures/XmlImports/pages-and-ttcontent-with-image-without-storage.xml',
90 1
91 );
92 $subject->importData(0);
93
94 $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/typo3_image2.jpg';
95
96 $this->assertCSVDataSet('EXT:impexp/Tests/Functional/Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithImagesButWithoutStorageOnCaseSensitiveFilesystems.csv');
97
98 $this->assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', PATH_site . 'fileadmin/user_upload/typo3_image2.jpg');
99 }
100
101 /**
102 * @test
103 */
104 public function importPagesAndRelatedTtContentWithImagesButWithoutStorageOnCaseInsensitiveFilesystems()
105 {
106 $subject = GeneralUtility::makeInstance(Import::class);
107 $subject->init();
108
109 if ($this->isCaseSensitiveFilesystem()) {
110 $this->markTestSkipped('Test not available on case sensitive filesystems.');
111 }
112
113 $subject->loadFile(
114 __DIR__ . '/../Fixtures/XmlImports/pages-and-ttcontent-with-image-without-storage.xml',
115 1
116 );
117 $subject->importData(0);
118
119 $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/typo3_image2.jpg';
120
121 $this->assertCSVDataSet('EXT:impexp/Tests/Functional/Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithImagesButWithoutStorageOnCaseInsensitiveFilesystems.csv');
122
123 $this->assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', PATH_site . 'fileadmin/user_upload/typo3_image2.jpg');
124 }
125
126 /**
127 * @test
128 */
129 public function importPagesAndRelatedTtContentWithImagesWithSpacesInPath()
130 {
131 $subject = GeneralUtility::makeInstance(Import::class);
132 $subject->init();
133
134 $subject->loadFile(
135 __DIR__ . '/../Fixtures/XmlImports/pages-and-ttcontent-with-image-with-spaces-in-path.xml',
136 1
137 );
138 $subject->importData(0);
139
140 $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/folder_with_spaces/typo3_image2.jpg';
141 $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/folder_with_spaces/typo3_image3.jpg';
142
143 $this->assertCSVDataSet('EXT:impexp/Tests/Functional/Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithImagesWithSpacesInPath.csv');
144
145 $this->assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', PATH_site . 'fileadmin/user_upload/folder_with_spaces/typo3_image2.jpg');
146 $this->assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image3.jpg', PATH_site . 'fileadmin/user_upload/folder_with_spaces/typo3_image3.jpg');
147 }
148
149 /**
150 * @test
151 */
152 public function importPagesAndRelatedTtContentWithImagesButNotIncluded()
153 {
154 $subject = GeneralUtility::makeInstance(Import::class);
155 $subject->init();
156
157 $subject->loadFile(
158 // 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
159 PATH_site . 'typo3/sysext/impexp/Tests/Functional/Fixtures/XmlImports/pages-and-ttcontent-with-image-but-not-included.xml',
160 1
161 );
162 $subject->importData(0);
163
164 $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/typo3_image2.jpg';
165
166 $this->assertCSVDataSet('EXT:impexp/Tests/Functional/Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithImagesButNotIncluded.csv');
167
168 $this->assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', PATH_site . 'fileadmin/user_upload/typo3_image2.jpg');
169 }
170
171 /**
172 * @test
173 * @group not-mssql
174 */
175 public function importPagesAndRelatedTtContentWithImageWithForcedUids()
176 {
177 $subject = GeneralUtility::makeInstance(Import::class);
178 $subject->init();
179
180 $subject->loadFile(
181 __DIR__ . '/../Fixtures/XmlImports/pages-and-ttcontent-with-image-with-forced-uids.xml',
182 1
183 );
184 $subject->force_all_UIDS = true;
185 $subject->importData(0);
186
187 $this->testFilesToDelete[] = PATH_site . 'fileadmin/user_upload/typo3_image2.jpg';
188
189 $this->assertCSVDataSet('EXT:impexp/Tests/Functional/Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithImageWithForcedUids.csv');
190
191 $this->assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', PATH_site . 'fileadmin/user_upload/typo3_image2.jpg');
192
193 $expectedErrors = [
194 'Forcing uids of sys_file records is not supported! They will be imported as new records!'
195 ];
196 $errors = $subject->errorLog;
197 $this->assertSame($expectedErrors, $errors);
198 }
199 }