‪TYPO3CMS  11.5
AbstractImportExportTestCase.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 Doctrine\DBAL\Platforms\SqlitePlatform;
21 use PHPUnit\Util\Xml\Loader as XmlLoader;
28 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
29 
33 abstract class ‪AbstractImportExportTestCase extends FunctionalTestCase
34 {
35  protected ‪$coreExtensionsToLoad = ['impexp', 'form'];
36 
41  protected array ‪$testFilesToDelete = [];
42 
47  protected function ‪setUp(): void
48  {
49  parent::setUp();
50 
51  $backendUser = $this->setUpBackendUserFromFixture(1);
52  $backendUser->workspace = 0;
54 
55  ‪$GLOBALS['TYPO3_REQUEST'] = (new ‪ServerRequest('https://www.example.com/'))
56  ->withAttribute('route', new ‪Route('/record/importexport/export', []))
57  ->withAttribute('applicationType', ‪SystemEnvironmentBuilder::REQUESTTYPE_BE)
58  ->withAttribute('normalizedParams', new ‪NormalizedParams([], [], '', ''));
59  }
60 
64  protected function ‪tearDown(): void
65  {
66  foreach ($this->testFilesToDelete as $absoluteFileName) {
67  if (@is_file($absoluteFileName)) {
68  unlink($absoluteFileName);
69  }
70  }
71  parent::tearDown();
72  }
73 
78  protected function ‪isCaseSensitiveFilesystem(): bool
79  {
80  $caseSensitive = true;
81  $path = GeneralUtility::tempnam('aAbB');
82 
83  // do the actual sensitivity check
84  if (@file_exists(strtoupper($path)) && @file_exists(strtolower($path))) {
85  $caseSensitive = false;
86  }
87 
88  // clean filesystem
89  unlink($path);
90  return $caseSensitive;
91  }
92 
105  public function ‪assertXmlStringEqualsXmlFileWithIgnoredSqliteTypeInteger(string $expectedFile, string $actualXml): void
106  {
107  $actual = (new XmlLoader())->load($actualXml);
108  $expectedFileContent = file_get_contents($expectedFile);
109  $databasePlatform = $this->getConnectionPool()->getConnectionForTable('pages')->getDatabasePlatform();
110  if ((PHP_VERSION_ID < 80100) && $databasePlatform instanceof SqlitePlatform) {
111  $expectedFileContent = str_replace(' type="integer"', '', $expectedFileContent);
112  }
113  $expected = (new XmlLoader())->load($expectedFileContent);
114  self::assertEquals($expected, $actual);
115  }
116 }
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
Definition: SystemEnvironmentBuilder.php:41
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\$testFilesToDelete
‪array $testFilesToDelete
Definition: AbstractImportExportTestCase.php:41
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_BE
‪const REQUESTTYPE_BE
Definition: SystemEnvironmentBuilder.php:45
‪TYPO3\CMS\Impexp\Tests\Functional
Definition: AbstractImportExportTestCase.php:18
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\assertXmlStringEqualsXmlFileWithIgnoredSqliteTypeInteger
‪assertXmlStringEqualsXmlFileWithIgnoredSqliteTypeInteger(string $expectedFile, string $actualXml)
Definition: AbstractImportExportTestCase.php:105
‪TYPO3\CMS\Backend\Routing\Route
Definition: Route.php:24
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\$coreExtensionsToLoad
‪$coreExtensionsToLoad
Definition: AbstractImportExportTestCase.php:35
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static initializeLanguageObject()
Definition: Bootstrap.php:598
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:37
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase
Definition: AbstractImportExportTestCase.php:34
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:70
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\tearDown
‪tearDown()
Definition: AbstractImportExportTestCase.php:64
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\isCaseSensitiveFilesystem
‪isCaseSensitiveFilesystem()
Definition: AbstractImportExportTestCase.php:78
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\setUp
‪setUp()
Definition: AbstractImportExportTestCase.php:47
‪TYPO3\CMS\Core\Http\NormalizedParams
Definition: NormalizedParams.php:35