‪TYPO3CMS  9.5
PagesAndTtContentWithImagesInFilledDatabaseTest.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 
21 
26 {
30  protected ‪$additionalFoldersToCreate = [
31  '/fileadmin/user_upload'
32  ];
33 
38  'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg' => 'fileadmin/user_upload/typo3_image2.jpg',
39  ];
40 
45  {
46  $subject = GeneralUtility::makeInstance(Import::class);
47  $subject->init();
48 
49  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/pages.xml');
50  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/tt_content-with-image.xml');
51  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_language.xml');
52  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file.xml');
53  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_metadata.xml');
54  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_reference.xml');
55  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_storage.xml');
56 
57  $subject->loadFile(
58  __DIR__ . '/../Fixtures/XmlImports/pages-and-ttcontent-with-existing-different-image.xml',
59  1
60  );
61  $subject->importData(0);
62 
63  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg';
64  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2_01.jpg';
65 
66  $this->assertCSVDataSet('EXT:impexp/Tests/Functional/Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithDifferentImageToExistingData.csv');
67 
68  $this->assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg');
69  $this->assertFileEquals(__DIR__ . '/../Fixtures/FileAssertions/typo3_image2_01.jpg', ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2_01.jpg');
70  }
71 
76  {
77  $subject = GeneralUtility::makeInstance(Import::class);
78  $subject->init();
79 
80  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/pages.xml');
81  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/tt_content-with-image.xml');
82  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_language.xml');
83  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file.xml');
84  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_metadata.xml');
85  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_reference.xml');
86  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_storage.xml');
87 
88  $subject->loadFile(
89  __DIR__ . '/../Fixtures/XmlImports/pages-and-ttcontent-with-existing-same-image.xml',
90  1
91  );
92  $subject->importData(0);
93 
94  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg';
95 
96  $this->assertCSVDataSet('EXT:impexp/Tests/Functional/Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithSameImageToExistingData.csv');
97 
98  $this->assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg');
99  }
100 
126  {
127  $subject = GeneralUtility::makeInstance(Import::class);
128  $subject->init();
129 
130  // Have a single sys_file entry with uid 1
131  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_single_image.xml');
132  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_storage.xml');
133 
134  // Import file with sys_file:1 and sys_file:2, where sys_file:1 has one connected
135  // content element, and sys_file:2 has two connected content elements.
136  $subject->loadFile(
137  __DIR__ . '/../Fixtures/XmlImports/pages-and-ttcontent-with-two-images.xml',
138  1
139  );
140  $subject->importData(0);
141 
142  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg';
143  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/used-1.jpg';
144  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/used-2.jpg';
145 
146  // Expect mapping is updated: one content element should still reference new sys_file:2,
147  // two others should reference new sys_file:3
148  $this->assertCSVDataSet('EXT:impexp/Tests/Functional/Fixtures/DatabaseAssertions/importPagesAndTtContentWithRemappingNewSysFileEntries.csv');
149  }
150 }
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:153
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInFilledDatabaseTest\$pathsToProvideInTestInstance
‪array $pathsToProvideInTestInstance
Definition: PagesAndTtContentWithImagesInFilledDatabaseTest.php:35
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInFilledDatabaseTest\importPagesAndRelatedTtContentWithDifferentImageToExistingData
‪importPagesAndRelatedTtContentWithDifferentImageToExistingData()
Definition: PagesAndTtContentWithImagesInFilledDatabaseTest.php:42
‪TYPO3\CMS\Impexp\Tests\Functional\Import
Definition: GroupFileAndFileReferenceItemInFlexFormTest.php:2
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInFilledDatabaseTest
Definition: PagesAndTtContentWithImagesInFilledDatabaseTest.php:26
‪TYPO3\CMS\Impexp\Import
Definition: Import.php:40
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInFilledDatabaseTest\$additionalFoldersToCreate
‪array $additionalFoldersToCreate
Definition: PagesAndTtContentWithImagesInFilledDatabaseTest.php:29
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase
Definition: AbstractImportExportTestCase.php:30
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInFilledDatabaseTest\importPagesAndTtContentWithRemappingNewSysFileEntries
‪importPagesAndTtContentWithRemappingNewSysFileEntries()
Definition: PagesAndTtContentWithImagesInFilledDatabaseTest.php:123
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInFilledDatabaseTest\importPagesAndRelatedTtContentWithSameImageToExistingData
‪importPagesAndRelatedTtContentWithSameImageToExistingData()
Definition: PagesAndTtContentWithImagesInFilledDatabaseTest.php:73