‪TYPO3CMS  ‪main
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 PHPUnit\Util\Xml\Loader as XmlLoader;
27 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
28 
32 abstract class ‪AbstractImportExportTestCase extends FunctionalTestCase
33 {
34  protected array ‪$coreExtensionsToLoad = ['impexp', 'form'];
35 
36  protected array ‪$testFilesToDelete = [];
37 
42  protected function ‪setUp(): void
43  {
44  parent::setUp();
45 
46  $this->importCSVDataSet(__DIR__ . '/Fixtures/DatabaseImports/be_users.csv');
47  $backendUser = $this->setUpBackendUser(1);
48  $backendUser->workspace = 0;
49  ‪$GLOBALS['LANG'] = $this->get(LanguageServiceFactory::class)->createFromUserPreferences($backendUser);
50 
51  ‪$GLOBALS['TYPO3_REQUEST'] = (new ‪ServerRequest('https://www.example.com/'))
52  ->withAttribute('route', new ‪Route('/record/importexport/export', []))
53  ->withAttribute('applicationType', ‪SystemEnvironmentBuilder::REQUESTTYPE_BE)
54  ->withAttribute('normalizedParams', new ‪NormalizedParams([], [], '', ''));
55  }
56 
60  protected function ‪tearDown(): void
61  {
62  foreach ($this->testFilesToDelete as $absoluteFileName) {
63  if (@is_file($absoluteFileName)) {
64  unlink($absoluteFileName);
65  }
66  }
67  parent::tearDown();
68  }
69 
74  protected function ‪isCaseSensitiveFilesystem(): bool
75  {
76  $caseSensitive = true;
77  $path = GeneralUtility::tempnam('aAbB');
78 
79  // do the actual sensitivity check
80  if (@file_exists(strtoupper($path)) && @file_exists(strtolower($path))) {
81  $caseSensitive = false;
82  }
83 
84  // clean filesystem
85  unlink($path);
86  return $caseSensitive;
87  }
88 
92  public function ‪assertXmlStringEqualsXmlFileWithIgnoredSqliteTypeInteger(string $expectedFile, string $actualXml): void
93  {
94  $actual = (new XmlLoader())->load($actualXml);
95  $expectedFileContent = file_get_contents($expectedFile);
96  $expected = (new XmlLoader())->load($expectedFileContent);
97  self::assertEquals($expected, $actual);
98  }
99 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
Definition: SystemEnvironmentBuilder.php:41
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\$testFilesToDelete
‪array $testFilesToDelete
Definition: AbstractImportExportTestCase.php:36
‪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\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: AbstractImportExportTestCase.php:34
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\assertXmlStringEqualsXmlFileWithIgnoredSqliteTypeInteger
‪assertXmlStringEqualsXmlFileWithIgnoredSqliteTypeInteger(string $expectedFile, string $actualXml)
Definition: AbstractImportExportTestCase.php:92
‪TYPO3\CMS\Backend\Routing\Route
Definition: Route.php:24
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:39
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase
Definition: AbstractImportExportTestCase.php:33
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\tearDown
‪tearDown()
Definition: AbstractImportExportTestCase.php:60
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\isCaseSensitiveFilesystem
‪isCaseSensitiveFilesystem()
Definition: AbstractImportExportTestCase.php:74
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\setUp
‪setUp()
Definition: AbstractImportExportTestCase.php:42
‪TYPO3\CMS\Core\Http\NormalizedParams
Definition: NormalizedParams.php:38