‪TYPO3CMS  10.4
PagesAndTtContentWithImagesInFilledDatabaseTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 
27 {
31  protected ‪$additionalFoldersToCreate = [
32  '/fileadmin/user_upload'
33  ];
34 
39  'typo3/sysext/impexp/Tests/Functional/Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg' => 'fileadmin/user_upload/typo3_image2.jpg',
40  ];
41 
46  {
47  $subject = GeneralUtility::makeInstance(Import::class);
48  $subject->init();
49 
50  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/pages.xml');
51  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/tt_content-with-image.xml');
52  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_language.xml');
53  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file.xml');
54  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_metadata.xml');
55  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_reference.xml');
56  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_storage.xml');
57 
58  $subject->loadFile(
59  __DIR__ . '/../Fixtures/XmlImports/pages-and-ttcontent-with-existing-different-image.xml',
60  1
61  );
62  $subject->importData(0);
63 
64  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg';
65  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2_01.jpg';
66 
67  $this->assertCSVDataSet('EXT:impexp/Tests/Functional/Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithDifferentImageToExistingData.csv');
68 
69  self::assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg');
70  self::assertFileEquals(__DIR__ . '/../Fixtures/FileAssertions/typo3_image2_01.jpg', ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2_01.jpg');
71  }
72 
77  {
78  $subject = GeneralUtility::makeInstance(Import::class);
79  $subject->init();
80 
81  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/pages.xml');
82  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/tt_content-with-image.xml');
83  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_language.xml');
84  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file.xml');
85  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_metadata.xml');
86  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_reference.xml');
87  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_storage.xml');
88 
89  $subject->loadFile(
90  __DIR__ . '/../Fixtures/XmlImports/pages-and-ttcontent-with-existing-same-image.xml',
91  1
92  );
93  $subject->importData(0);
94 
95  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg';
96 
97  $this->assertCSVDataSet('EXT:impexp/Tests/Functional/Fixtures/DatabaseAssertions/importPagesAndRelatedTtContentWithSameImageToExistingData.csv');
98 
99  self::assertFileEquals(__DIR__ . '/../Fixtures/Folders/fileadmin/user_upload/typo3_image2.jpg', ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg');
100  }
101 
127  {
128  $subject = GeneralUtility::makeInstance(Import::class);
129  $subject->init();
130 
131  // Have a single sys_file entry with uid 1
132  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_single_image.xml');
133  $this->importDataSet(__DIR__ . '/../Fixtures/DatabaseImports/sys_file_storage.xml');
134 
135  // Import file with sys_file:1 and sys_file:2, where sys_file:1 has one connected
136  // content element, and sys_file:2 has two connected content elements.
137  $subject->loadFile(
138  __DIR__ . '/../Fixtures/XmlImports/pages-and-ttcontent-with-two-images.xml',
139  1
140  );
141  $subject->importData(0);
142 
143  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/typo3_image2.jpg';
144  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/used-1.jpg';
145  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/fileadmin/user_upload/used-2.jpg';
146 
147  // Expect mapping is updated: one content element should still reference new sys_file:2,
148  // two others should reference new sys_file:3
149  $this->assertCSVDataSet('EXT:impexp/Tests/Functional/Fixtures/DatabaseAssertions/importPagesAndTtContentWithRemappingNewSysFileEntries.csv');
150  }
151 }
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:180
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInFilledDatabaseTest\$pathsToProvideInTestInstance
‪array $pathsToProvideInTestInstance
Definition: PagesAndTtContentWithImagesInFilledDatabaseTest.php:36
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInFilledDatabaseTest\importPagesAndRelatedTtContentWithDifferentImageToExistingData
‪importPagesAndRelatedTtContentWithDifferentImageToExistingData()
Definition: PagesAndTtContentWithImagesInFilledDatabaseTest.php:43
‪TYPO3\CMS\Impexp\Tests\Functional\Import
Definition: IrreTutorialRecordsTest.php:16
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInFilledDatabaseTest
Definition: PagesAndTtContentWithImagesInFilledDatabaseTest.php:27
‪TYPO3\CMS\Impexp\Import
Definition: Import.php:42
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInFilledDatabaseTest\$additionalFoldersToCreate
‪array $additionalFoldersToCreate
Definition: PagesAndTtContentWithImagesInFilledDatabaseTest.php:30
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase
Definition: AbstractImportExportTestCase.php:31
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInFilledDatabaseTest\importPagesAndTtContentWithRemappingNewSysFileEntries
‪importPagesAndTtContentWithRemappingNewSysFileEntries()
Definition: PagesAndTtContentWithImagesInFilledDatabaseTest.php:124
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Impexp\Tests\Functional\Import\PagesAndTtContentWithImagesInFilledDatabaseTest\importPagesAndRelatedTtContentWithSameImageToExistingData
‪importPagesAndRelatedTtContentWithSameImageToExistingData()
Definition: PagesAndTtContentWithImagesInFilledDatabaseTest.php:74