‪TYPO3CMS  11.5
ImportExportUtilityTest.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 Prophecy\PhpUnit\ProphecyTrait;
21 use Psr\EventDispatcher\EventDispatcherInterface;
24 
26 {
27  use ProphecyTrait;
28 
29  public function ‪importFailsDataProvider(): array
30  {
31  return [
32  'path to not existing file' => [
33  'EXT:impexp/Tests/Functional/Fixtures/XmlImports/me_does_not_exist.xml',
34  ],
35  'unsupported file extension' => [
36  'EXT:impexp/Tests/Functional/Fixtures/XmlImports/unsupported.json',
37  ],
38  'missing required extension' => [
39  'EXT:impexp/Tests/Functional/Fixtures/XmlImports/sys_category_table_with_news.xml',
40  ],
41  ];
42  }
43 
48  public function ‪importFails(string $filePath): void
49  {
50  $this->expectException(\ErrorException::class);
51  $this->expectExceptionMessage('No page records imported');
52 
53  $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
54  $importUtilityMock = $this->getAccessibleMock(
55  ImportExportUtility::class,
56  ['dummy'],
57  ['eventDispatcher' => $eventDispatcher->reveal()]
58  );
59  $importUtilityMock->importT3DFile($filePath, 0);
60  }
61 
65  public function ‪importSucceeds(): void
66  {
67  $filePath = 'EXT:impexp/Tests/Functional/Fixtures/XmlImports/pages-and-ttcontent.xml';
68 
69  $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
70  $importUtilityMock = $this->getAccessibleMock(
71  ImportExportUtility::class,
72  ['dummy'],
73  ['eventDispatcher' => $eventDispatcher->reveal()]
74  );
75  $result = $importUtilityMock->importT3DFile($filePath, 0);
76 
77  self::assertEquals(1, $result);
78  }
79 }
‪TYPO3\CMS\Impexp\Tests\Functional\Utility\ImportExportUtilityTest\importSucceeds
‪importSucceeds()
Definition: ImportExportUtilityTest.php:64
‪TYPO3\CMS\Impexp\Tests\Functional\Utility\ImportExportUtilityTest\importFails
‪importFails(string $filePath)
Definition: ImportExportUtilityTest.php:47
‪TYPO3\CMS\Impexp\Tests\Functional\Utility\ImportExportUtilityTest\importFailsDataProvider
‪importFailsDataProvider()
Definition: ImportExportUtilityTest.php:28
‪TYPO3\CMS\Impexp\Tests\Functional\Utility
Definition: ImportExportUtilityTest.php:18
‪TYPO3\CMS\Impexp\Utility\ImportExportUtility
Definition: ImportExportUtility.php:33
‪TYPO3\CMS\Impexp\Tests\Functional\Utility\ImportExportUtilityTest
Definition: ImportExportUtilityTest.php:26
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase
Definition: AbstractImportExportTestCase.php:34